Jabop Posted August 6, 2008 Share Posted August 6, 2008 I have read some debate on a few sites about the two joins. Most state that LEFT JOIN WHERE x IS NOT NULL is faster and more efficient than an INNER JOIN. I've done a few benches with a few of the tables that I have, at only about 14k records - which I understand isn't much - but I got the same results with both queries. SELECT ac.Referrer, a.Name FROM advertisementclicks AS ac LEFT JOIN advertisements AS a ON a.ID = ac.AdvertisementID WHERE a.ID IS NOT NULL Showing rows 0 - 29 (13,975 total, Query took 0.0011 sec) SELECT ac.Referrer, a.Name FROM advertisementclicks AS ac INNER JOIN advertisements AS a ON a.ID = ac.AdvertisementID Showing rows 0 - 29 (13,975 total, Query took 0.0011 sec) Does anyone have any information on this, care to debunk or back this up, or elaborate? Link to comment https://forums.phpfreaks.com/topic/118487-inner-join-vs-left-join-where-x-is-not-null/ Share on other sites More sharing options...
fenway Posted August 6, 2008 Share Posted August 6, 2008 There's no difference in this case, the optimizer will figure that out right away... so you're not really testing anything. The difference will come about when there are NULL values in the join-ed field during the LEFT JOIN. Link to comment https://forums.phpfreaks.com/topic/118487-inner-join-vs-left-join-where-x-is-not-null/#findComment-610114 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.