Lost connection to MySQL server during query with UNION

128
December 22, 2017, at 04:35 AM

i am getting error Lost connection to MySQL server during query with UNION query bellow.

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

Strange thing is that if i remove the last line entirely or if i sort by id instead of name it works fine.

Any ideas what could possibly be wrong with this?

READ ALSO
Cron Jobs / Scheduled Tasks for Multi-Tenant PHP app

Cron Jobs / Scheduled Tasks for Multi-Tenant PHP app

Hoping I can get some help (again)I'm working on a multi-tenant PHP application

86
Group_by in Django Database | Most efficient query order

Group_by in Django Database | Most efficient query order

I'm working on an old django app which unfortunately has one giant table in the database, meaning conventionally our queries are very slow

81
— PSQL to Mysql— MySQL Migration Toolkit keeps freezing at reading rows

— PSQL to Mysql— MySQL Migration Toolkit keeps freezing at reading rows

I am able to get through all of the migration wizard except for the second to last stepIT just sits at determining number of rows

62
How to run two or more sql query at the same time?

How to run two or more sql query at the same time?

I want to run more query at the really same time in different threadI am using backgroundworkers to solve this problem! My question is: Is there better way to delegate UI element or is it correct as i did it?

158