Mike Pala Mike Pala - 1 year ago 66
SQL Question

JOIN and SELECT values not included in table2

I appreciate this might be very simple for you guys but sometimes the logic behind JOIN can be difficult for beginners. I want to select "ID" from table1 but only those "ID"s which do NOT appear in table2."ID". I tested LEFT and RIGHT but cannot get it to work the way I need to. I am using dashDB.

Answer Source

You can use NOT IN and subquery

Select * from table1 where id NOT IN (select id from table2);