Search code examples
sql-servert-sqlinner-joinouter-join

Opposite Of An Inner Join Query


Table 1 2 columns: ID, Name

Table 2 2 columns: ID, Name

What is a query to show names from Table 1 that are not in table 2? So filtering out all the names in table 1 that are in table 2 gives the result query. Filtering is on ID not name.


Solution

  • Select * from table1
    left join table2 on table1.id = table2.id
    where table2.id is null