0

I have one SQL query , in that query i joined three tables and i run in SQL QUERY it is showing some error, i am not getting why this error coming ,if anyone knows means please update my code

my error is: #2013 - Lost connection to MySQL server during query

My SQL QUERY

SELECT tm.empId,a.companyId,a.tripId,a.startTime,a.endTime,a.tripDate,c.shiftTiming,c.routeId,c.cabId, a.forceEndStatus,a.tripStatus,c.type, (
    select count('*') 
    from trip_member as m 
    WHERE m.tripId=a.tripId and m.empPresentStatus = '1'
) as absentcount,(
    select count('*') 
    from trip_member as m 
    WHERE m.tripId=a.tripId and m.empPresentStatus = '0'
) as presentcount ,(
    select count('*') 
    from trip_member as m 
    WHERE m.tripId=a.tripId and m.pickupotpStatus = '1'
) as pickupcount  
FROM trip_details a 
INNER JOIN cab_allocation as c 
on c.allocationId = a.allocationId 
LEFT JOIN trip_member tm 
ON a.tripId = tm.tripId 
where c.companyId = '1' 
order by a.id desc 
LIMIT 0,30

Suppose i am removing LEFT JOIN trip_member tm ON a.tripId = tm.tripId means it is working fine,

Romain B.
  • 656
  • 6
  • 15
  • Hard to know whether this is a duplicate of https://stackoverflow.com/questions/6516943/lost-connection-to-mysql-server-during-query or https://stackoverflow.com/questions/1884859/lost-connection-to-mysql-server-during-query – Chris Lear Feb 21 '18 at 10:10
  • Maybe have a look at https://dev.mysql.com/doc/refman/5.7/en/gone-away.html – Chris Lear Feb 21 '18 at 10:11
  • I am running this query in server,i am getting error like this – Kumaresan M Feb 21 '18 at 10:15
  • Suppose i have to optimized mysql query, please any one check my sql query is correct or not ? – Kumaresan M Feb 21 '18 at 10:16
  • My trip_member table i have 25000 records , i think because of this my SQL query in not executing, – Kumaresan M Feb 21 '18 at 10:29

0 Answers0