jbradley04 Posted August 6, 2015 Share Posted August 6, 2015 Hello all, I am trying to find a user that is NOT IN another table. Here is the code I have but it is not working. Any help would be greatly appreciated! select * from user as u, where u.GroupID=9 and u.ID NOT IN (SELECT CBy FROM stories WHERE Con BETWEEN '2014-07' AND '2015-07' AND CBy IS NOT NULL) Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/297663-find-a-user-not-in-another-table-for-specified-dates/ Share on other sites More sharing options...
Barand Posted August 6, 2015 Share Posted August 6, 2015 Joins are usually more efficient SELECT * FROM USER u LEFT JOIN stories s ON u.ID = s.CBy AND s.con BETWEEN '2014-07' AND '2015-07' WHERE s.CBy IS NULL BTW, you shouldn't have had the comma at the end of your first line Link to comment https://forums.phpfreaks.com/topic/297663-find-a-user-not-in-another-table-for-specified-dates/#findComment-1518155 Share on other sites More sharing options...
jbradley04 Posted August 7, 2015 Author Share Posted August 7, 2015 Worked perfect! Thanks. Link to comment https://forums.phpfreaks.com/topic/297663-find-a-user-not-in-another-table-for-specified-dates/#findComment-1518188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.