how to check which record does not exists in one table to another table in sql server?

Asked 19-May-2018
Updated 19-May-2018
Viewed 690 times

0

how to check which record does not exists in one table to another table in sql server?

for example we have two table like table1 and table2 . i want to select all table1 record which does not exists in table2.


1 Answer


0

Use not exists keyword to select first table record which does not exist in the second table.

Here, is the Query string

SELECT t1.name FROM
table1 t1
WHERE NOT EXISTS (
SELECT * FROM table2 t2
WHERE t2.id = t1.id)