Opposite Of An Inner Join Query

Nick LaMarca picture Nick LaMarca · Oct 28, 2010 · Viewed 55k times · Source

can someone help me write sql for a scernerio like this:

Table 1

2 columns: ID, Name

Table 2

2 columns: ID, Name

I want a query to show names from Table 1 that are not in table 2. So filter out all the names in table 1 that are in table 2 is the result query. Use ID for the filtering not name.

This will help me in what I am trying to do. Thanks in advance

Answer

Andrew picture Andrew · Oct 28, 2010
Select * from table1
left join table2 on table1.id = table2.id
where table2.id is null