如何更改表

时间:2018-02-21 12:14:04

标签: mysql sql

这里我有一个sql查询工作正常,就像trip_member表名

假设trip_member共有20条记录,这意味着我的SQL查询执行得非常完美,并且还能完美地返回响应。

我的查询

SELECT tm.empId, tm.pickupTime, tm.dropTime, td.companyId, td.tripId, td.startTime, td.endTime, td.tripDate, td.forceEndStatus, td.tripStatus, c.shiftTiming, c.routeId, c.cabId,(select count('*') from trip_member as m WHERE m.tripId=td.tripId and m.empPresentStatus = '1') as absentcount,(select count('*') from trip_member as m WHERE m.tripId=td.tripId and m.empPresentStatus = '0') as presentcount,(select count('*') from trip_member as m WHERE m.tripId=td.tripId and m.pickupotpStatus = '1') as pickupcount
FROM trip_member tm
LEFT JOIN trip_details td ON tm.`tripId` = td.`tripId` 
INNER JOIN cab_allocation c ON c.`allocationId` = td.`allocationId` WHERE c.companyId = '1' 
ORDER BY td.`id` DESC 
LIMIT 10

但我的trip_member表我有20k记录,假设我正在执行查询现在意味着我收到这样的错误

  

#2013 - 查询期间与MySQL服务器的连接丢失

我想我必须在我的表中使用索引,但我不知道如何使用索引以及我使用索引的哪些字段,如果有人知道请更新你的sql alter query in index

0 个答案:

没有答案