Guest Posted May 7, 2009 Share Posted May 7, 2009 Im not sure how to go about this or even ask but lets say i have two tables table a has 1 2 3 table b has 1 2 3 4 5 Im trying to think of a way where I can select blank from tableb where the number isnt in table a order by first number thats not in a I have tried subquerying like this SELECT ID FROM TableA WHERE ID NOT IN (SELECT ID FROM TableB) ORDER BY ID ASC LIMIT 1 Im not even sure that works because it basically kills the server and runs way to long for me to even figure out if its what i want. Any help or points in the right direction will be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/157178-not-in-other-table/ Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Well you have 2 tables with the same column name so it's confusing. SELECT ta.id FROM tableA ta WHERE ta.id NOT IN (SELECT tb.id FROM tableB tb) LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/157178-not-in-other-table/#findComment-828259 Share on other sites More sharing options...
fenway Posted May 7, 2009 Share Posted May 7, 2009 Or a LEFT JOIN ... IS NULL, so as not to kill performance. Quote Link to comment https://forums.phpfreaks.com/topic/157178-not-in-other-table/#findComment-828722 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.