查看执行的sql 代码, 然后开启mysql 的 general_log

set global general_log='on';
show variables  like "%general_log%";
set global general_log='off';

其中, 中间,在程序触发排序

SELECT mt.* ,ds.ps_count FROM
        (select

        do.id,
        do.logistics_company_id,
        do.order_no,
        do.lable_info,
        do.ext_order_no,
        do.ext_order_no2,
        do.ext_po_no,
        do.owner_id,
        co.owner_name AS owner_name,
        do.shop_id,
        sm.description AS shop_name,
        do.warehouse,
        iw.description as warehouse_name,
        do.delivery_type,
        do.order_type,
        do.rowstate,
        do.receiver,
        do.province,
        do.city,
        do.country,
        do.address,
        do.mobile_no,
        do.merge_info,
        do.invoice_title,
        do.product_weight,
        do.expr_company,
        do.expr_bill_no,
        do.order_date,
        do.paid_date,
        do.picked_date,
        do.shipped_date,
        do.deal_hours,
        do.buyer_note,
        do.seller_note,
        do.note_text,
        do.buyer_id,
        do.id_card_no,
        do.sender,
        do.sender_mobile,
        do.sender_province,
        do.sender_city,
        do.sender_country,
        do.sender_addr,
        do.pick_list_no,
        do.expr_printed,
        do.bill_printed,
        do.pick_type,
        do.part_count,
        do.part_list,
        do.ean_no_list,
        do.part_no_list,
        do.shortage_flag,
        do.pkg_weight,
        do.sync_flag,
        do.create_order_type,
        do.error_msg,
        do.created_date,
        do.created_user,
        do.updated_date,
        do.updated_user,
        do.cut_reason,
        do.goods_count

        from delivery_order do
        LEFT JOIN company_owner co ON co.logistics_company_id = 10000 AND co.owner_id = do.owner_id
        LEFT JOIN shop_mall sm ON sm.logistics_company_id = 10000 AND sm.shop_id = do.shop_id
        LEFT JOIN inventory_warehouse iw ON iw.logistics_company_id = 10000 AND iw.warehouse =do.warehouse
        where 1=1 AND do.logistics_company_id = 10000

            AND do.rowstate IN
             (
                2
             ,
                3
             ,
                4
             ,
                5
             ,
                6
             ,
                7
             ,
                8
             )



























        )AS mt
        LEFT JOIN
        (SELECT do2.id,do2.part_list,ps.ps_count from delivery_order as do2
            LEFT JOIN
            (SELECT
                part_list,
                (CASE
                WHEN (COUNT(*) > 0) THEN COUNT(*)
                ELSE 0
                END) AS ps_count FROM delivery_order WHERE rowstate = 2 GROUP BY part_list) AS ps
            ON do2.part_list = ps.part_list  and  do2.rowstate = 2
        ) as ds
        ON mt.id = ds.id
        WHERE 1=1






                        order by rowstate ASC LIMIT 0,30

执行的sql 确实有排序

但是实际执行的效果是在程序的客户端,确实没有排序 ,

拿这个sql 语句, 在数据库, 用工具执行, 确实会排序 ,

03-16 15:26