How to return rows from left table not found in right table?

StarJedi picture StarJedi · Sep 5, 2014 · Viewed 171k times · Source

I have two tables with similar column names and I need to return records from the left table which are not found in the right table? I have a primary key(column) which will help me to compare both tables. Which join is preferred?

Answer

Shamseer K picture Shamseer K · Jun 25, 2016

Try This

SELECT f.*
FROM first_table f LEFT JOIN second_table s ON f.key=s.key
WHERE s.key is NULL

For more please read this article : Joins in Sql Server

enter image description here