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

0 votes
71 views
aditya kumar Patel asked 19-May-2018 in Technology by aditya kumar Patel
edited 19-May-2018 by Harsh-Srivastava

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 votes
Arti Mishra answered 19-May-2018 by Arti Mishra

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)