brown2005 Posted July 17, 2006 Share Posted July 17, 2006 hi,say i have table 1--------------members_idmembers_nameand then table 2selected_idwat i want to do is select all the records in table 1 that do not have their id in table 2? Link to comment https://forums.phpfreaks.com/topic/14828-slect-a-record-that-is-in-table-1-but-not-in-table-2/ Share on other sites More sharing options...
hvle Posted July 17, 2006 Share Posted July 17, 2006 my sql is rusty but try this, don't yell if it doesn't work:$sql = "select * from table1 where members_id not in (select selected_id from table2 where 1)"; Link to comment https://forums.phpfreaks.com/topic/14828-slect-a-record-that-is-in-table-1-but-not-in-table-2/#findComment-59271 Share on other sites More sharing options...
micah1701 Posted July 17, 2006 Share Posted July 17, 2006 I think hvle's is a little better then mine, i would do"SELECT table_1.id FROM table_1.id WHERE (SELECT id FROM table_2.id WHERE table_2.id NOT LIKE table1.id)";but again, don't yell at me if it doesn't work. Link to comment https://forums.phpfreaks.com/topic/14828-slect-a-record-that-is-in-table-1-but-not-in-table-2/#findComment-59273 Share on other sites More sharing options...
ShogunWarrior Posted July 17, 2006 Share Posted July 17, 2006 Another Option, I think:"SELECT table_1.id,table_1.id as t1id FROM table_1 WHERE (SELECT COUNT(*) FROM table_2 WHERE table_2.id=t1id) < 1" Link to comment https://forums.phpfreaks.com/topic/14828-slect-a-record-that-is-in-table-1-but-not-in-table-2/#findComment-59316 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.