1. 程式人生 > >guns spring 利用 mybatis 生成的包含排序的sql ,相同的程式碼 在不同的資料庫,一個可以排序,一個不可以

guns spring 利用 mybatis 生成的包含排序的sql ,相同的程式碼 在不同的資料庫,一個可以排序,一個不可以

開發十年,就只剩下這套架構體系了! >>>   

檢視執行的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 語句, 在資料庫, 用工具執