我有这两个我正在运行的查询。第一个工作,但由于某种原因,EXISTS()函数似乎增加了大约一分钟的加载时间,这使得它难以忍受。所以我写了第二个查询,我觉得应该给出相同的答案,但它给出了一个非常不同的答案。给出不同结果的两个MySQL查询
首先
select
count(`FavoritesHeaderID`) `count`
from `favoritesheader`
join `vwactiveevent` on `vwactiveevent`.`MainEventID`=`favoritesheader`.`MainEventID`
where `Admin`=0
and exists(
select 1
from `invoiceheader`
join `vwactiveevent` on `vwactiveevent`.`MainEventID`=`invoiceheader`.`MainEventID`
where `Phone`=`favoritesheader`.`CellPhone`
and `OrderStatusID`=2
); => 284
二
select
count(`FavoritesHeaderID`) `count`
from `favoritesheader`
join `vwactiveevent` on `vwactiveevent`.`MainEventID`=`favoritesheader`.`MainEventID`
join `invoiceheader` on `vwactiveevent`.`MainEventID`=`invoiceheader`.`MainEventID`
where `Admin`=0
and `Phone`=`favoritesheader`.`CellPhone`
and `OrderStatusID`=2; => 1578
我不知道,如果只是这是足够的信息来熄灭的,但如果它是那么任何帮助将非常赞赏。
关于什么的结果不同? – Joe
我的不好,现在更新 –