记录mysql中连表查询后根据时间排序,结果没有排序

连表查询订单下单时间后根据下单时间倒叙排序,如下sql执行后没有实现排序

        select
        items.id as id,
        items.reap_user_mess as reapUserMess,
        items.sum_profit as sumProfit,
        items.shop_user_id as shopUserId,
        items.payer_id as payerId,
        items.pay_type as payType,
        items.user_id as userId,
        items.address_id as addressId,
        items.user_name as userName,
        items.user_address as userAddress,
        items.shop_id as shopId,
        items.shop_name as shopName,
        items.order_id as orderId,
        items.user_moblie as userMobile,
        items.coupon as coupon,
        items.discount_amount as discountAmount,
        items.integral as integral,
        items.integral_amount as integralAmount,
        items.shipping_fee as shippingFee,
        items.produnt_sum_amount as produntSumAmount,
        items.amount as amount,
        items.product_count as productCount,
        items.order_status as orderStatus,
        items.del_stats as delStats,
        items.pay_time as payTime,
        items.reap_time as reapTime,
        items.shut_time as shutTime,
        items.finish_time as finishTime,
        items.del_reson as delReson,
        items.check_status as checkStatus,
        items.discount as discount,
        items.seller_rate_status as sellerRatestatus,
        items.buyer_rate_status as buyerRateStatus,
        items.close_reason as closeReason,
        items.close_remark as closeRemark,
        items.over_time as overTime,
        items.shop_activity as shopActivity,
        items.supplier_user_id as supplierUserId,
        detail.shop_user_id as shopUserId,
        items.supplier_id as supplierId,
        items.province as province,
        items.create_time as createTime,
        items.city as city,
        items.area as area,
        items.delivery_user_name as deliveryUserName,
        items.delivery_mobile as deliveryMobile,
        items.payer_remark as payerRemark,
        items.seller_remark as sellerRemark,
        items.order_descrition as orderDescrition,
        detail.product_id as productId,
        detail.sku_id as skuId,
        detail.product_type as productType,
        detail.product_name as productName,
        detail.product_descrition as productDescrition,
        detail.product_specs as productSpecs,
        detail.product_amount as productAmount,
        detail.product_price as productPrice,
        detail.product_num as productNum,
        detail.product_url as productUrl,
        detail.send_time as sendTime,
        detail.weight as weight,
        detail.weight_unit as weightUnit,
        detail.product_profit as productProfit,
        detail.child_order_id as childOrderId,
        detail.child_order_status as childOrderStatus,
        detail.remarks as remarks,
        detail.delivery_type as deliveryType,
        detail.change_price as changePrice,
        refund.refund_type as refundType,
        refundDetail.refund_status as refundStatus
        from order_item items left join order_detail detail on items.order_id = detail.order_id
        left join order_refund refund on detail.order_id = refund.order_id and detail.sku_id = refund.sku_id
        left join refund_order_detail refundDetail on refundDetail.refund_order_id = refund.refund_order_id
        where items.user_id = 137 and items.order_status != 5
       order BY detail.create_time desc
        limit 0,10
原因是:没有将要排序的字段查询出来
修改后的sql
```
        select
    items.id as id,
    items.reap_user_mess as reapUserMess,
    items.sum_profit as sumProfit,
    items.shop_user_id as shopUserId,
    items.payer_id as payerId,
    items.pay_type as payType,
    items.user_id as userId,
    items.address_id as addressId,
    items.user_name as userName,
    items.user_address as userAddress,
    items.shop_id as shopId,
    items.shop_name as shopName,
    items.order_id as orderId,
    items.user_moblie as userMobile,
    items.coupon as coupon,
    items.discount_amount as discountAmount,
    items.integral as integral,
    items.integral_amount as integralAmount,
    items.shipping_fee as shippingFee,
    items.produnt_sum_amount as produntSumAmount,
    items.amount as amount,
    items.product_count as productCount,
    items.order_status as orderStatus,
    items.del_stats as delStats,
    items.pay_time as payTime,
    items.reap_time as reapTime,
    items.shut_time as shutTime,
    items.finish_time as finishTime,
    items.del_reson as delReson,
    items.check_status as checkStatus,
    items.discount as discount,
    items.seller_rate_status as sellerRatestatus,
    items.buyer_rate_status as buyerRateStatus,
    items.close_reason as closeReason,
    items.close_remark as closeRemark,
    items.over_time as overTime,
    items.shop_activity as shopActivity,
    items.supplier_user_id as supplierUserId,
    detail.shop_user_id as shopUserId,
    items.supplier_id as supplierId,
    items.province as province,
    items.create_time as createTime,
    items.city as city,
    items.area as area,
    items.delivery_user_name as deliveryUserName,
    items.delivery_mobile as deliveryMobile,
    items.payer_remark as payerRemark,
    items.seller_remark as sellerRemark,
    items.order_descrition as orderDescrition,
    detail.product_id as productId,
    detail.sku_id as skuId,
    detail.product_type as productType,
    detail.product_name as productName,
    detail.product_descrition as productDescrition,
    detail.product_specs as productSpecs,
    detail.product_amount as productAmount,
    detail.product_price as productPrice,
    detail.product_num as productNum,
    detail.product_url as productUrl,
    detail.send_time as sendTime,
    detail.weight as weight,
			detail.create_time as createTime,
    detail.weight_unit as weightUnit,
    detail.product_profit as productProfit,
    detail.child_order_id as childOrderId,
    detail.child_order_status as childOrderStatus,
    detail.remarks as remarks,
    detail.delivery_type as deliveryType,
    detail.change_price as changePrice,
    refund.refund_type as refundType,
    refundDetail.refund_status as refundStatus
    from order_item items left join order_detail detail on items.order_id = detail.order_id
    left join order_refund refund on detail.order_id = refund.order_id and detail.sku_id = refund.sku_id
    left join refund_order_detail refundDetail on refundDetail.refund_order_id = refund.refund_order_id
    where items.user_id = 137 and items.order_status != 5
   order BY detail.create_time desc
    limit 0,10     

发布了26 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_42643690/article/details/102609983