使用UNION查询期间与MySQL服务器的连接丢失

时间:2017-12-21 17:38:03

标签: mysql

我收到错误Lost connection to MySQL server during query时出现UNION查询。

select * 
from `dealers` 
where   exists ((
            select * 
            from `cars` 
            where `dealers`.`id` = `cars`.`dealer_id` 
               and exists (select * 
                           from `dealers` 
                           where `cars`.`dealer_id` = `dealers`.`id`)  
               and `dealer_id` = 27 
               order by `price` asc)

            union (select * 
                   from `cars` 
                   where `dealers`.`id` = `cars`.`dealer_id` 
                   and exists (select * 
                               from `dealers` 
                               where `cars`.`dealer_id` = `dealers`.`id`) 
                               and `dealer_id` != 27 
                               order by `price` desc)) 

order by `dealers`.`name` asc

奇怪的是,如果我完全删除最后一行,或者我按id而不是name排序,则可以正常工作。

任何想法都可能出错?

0 个答案:

没有答案