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! Quote 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 (edited) 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 Edited August 6, 2015 by Barand Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.