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! Link to comment https://forums.phpfreaks.com/topic/275238-help-selecting-what-is-not-in-two-tables/ Share on other sites More sharing options...
Jessica Posted March 4, 2013 Share Posted March 4, 2013 SELECT ClassDetail.CLID FROM ClassDetail LEFT JOIN Classes ON Classes.CLID = ClassDetail.CLID WHERE Classes.CLID IS NULLNot tested. 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! 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
Archived
This topic is now archived and is closed to further replies.