mcmuney Posted December 31, 2011 Share Posted December 31, 2011 What's wrong with the statement below? I'm not getting any results, but I know for a fact that there should be results. What I'm trying to do is this: Take ALL id's from table member, then compare it with table member_images and display ONLY the id's that DOES NOT exist in member_images $sel_mem="SELECT id FROM member AS members LEFT JOIN member_images AS images ON members.id = images.id WHERE members.id IS NULL LIMIT 5"; Quote Link to comment https://forums.phpfreaks.com/topic/254117-left-join-is-null-issue/ Share on other sites More sharing options...
sunfighter Posted December 31, 2011 Share Posted December 31, 2011 Try this: SELECT * FROM member LEFT OUTER JOIN member_images ON member.id = member_images.id WHERE member_images.id IS null Quote Link to comment https://forums.phpfreaks.com/topic/254117-left-join-is-null-issue/#findComment-1302814 Share on other sites More sharing options...
AyKay47 Posted December 31, 2011 Share Posted December 31, 2011 Then the table on the right is not returning a match with the table on the left, which will set the right table values to null. You want an outer join. Quote Link to comment https://forums.phpfreaks.com/topic/254117-left-join-is-null-issue/#findComment-1302837 Share on other sites More sharing options...
sunfighter Posted December 31, 2011 Share Posted December 31, 2011 I think I said that AyKay47, didn't I? Quote Link to comment https://forums.phpfreaks.com/topic/254117-left-join-is-null-issue/#findComment-1302857 Share on other sites More sharing options...
AyKay47 Posted December 31, 2011 Share Posted December 31, 2011 no, you said "Try this:" which doesn't teach the OP anything. I said in english what you wrote in code. Quote Link to comment https://forums.phpfreaks.com/topic/254117-left-join-is-null-issue/#findComment-1302937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.