benphp Posted March 4, 2013 Share Posted March 4, 2013 I have two tables: Classes CLID | CLDate ClassDetail CLID | Description | Instructor I'm trying to figure out a single SQL statement that would return all CLIDs that exist in ClassDetail but NOT in Classes. I'm in the process of fudging it in PHP, but I know there's a better way... Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/275238-help-selecting-what-is-not-in-two-tables/ Share on other sites More sharing options...
Solution Jessica Posted March 4, 2013 Solution Share Posted March 4, 2013 SELECT ClassDetail.CLID FROM ClassDetail LEFT JOIN Classes ON Classes.CLID = ClassDetail.CLID WHERE Classes.CLID IS NULLNot tested. Quote Link to comment https://forums.phpfreaks.com/topic/275238-help-selecting-what-is-not-in-two-tables/#findComment-1416528 Share on other sites More sharing options...
benphp Posted March 4, 2013 Author Share Posted March 4, 2013 That does it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/275238-help-selecting-what-is-not-in-two-tables/#findComment-1416530 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.