Reputation: 7840
table1
row 1
row 2
row 3
table2
row 1
Want query which show only rows of table1 which is not in table2
result
row 2
row 3
Upvotes: 0
Views: 54
Reputation: 35464
select table1.col1 from table1
where not exists
(select table2.col1 from table2 where table1.col1 = table2.col1)
Upvotes: 1
Reputation: 434985
SQL set operators are your friend:
SELECT row FROM table1
EXCEPT
SELECT row FROM table2
Or you can use NOT IN
:
SELECT row
FROM table1
WHERE row NOT IN (SELECT row FROM table)
These assume that your tables have one column called row
and that the columns are the same type. You should be able to adapt them to your real tables easily enough though.
Upvotes: 2