【发布时间】:2021-09-24 03:39:59
【问题描述】:
我正在编写一个带有左连接的 MySQL 查询,当我删除并使用左连接条件时,它会在 28 秒内给我结果,然后它会在一秒钟内工作,谁能告诉我查询中的问题是什么以及它将如何修改了吗?
select *
FROM regist_queue rq
left join appoint ap
on rq.token_number = ap.daily_ticket_no
and rq.LocationId = 15800
and ap.LocationId = 15800
and date(rq.QueueDate) = CURRENT_DATE()
and date(ap.dAppDate) = date(now())
left join patient pr
on ap.iPatID = pr.IPatID
left join gender ge
on pr.vGender = ge.iGenderID
where ifnull(ap.isDel,0) = 0
and ifnull(ap.is_referred,0) != 1
and (ap.LocationId = 15800 or rq.LocationId = 15800 )
order by rq.token_number asc;
【问题讨论】:
-
Explainof command 会很有用。 -
我已经用查询计划图像更新了我的查询。
标签: mysql