HI WELCOME TO KANSIRIS

How to select all records from one table that do not exist in another table?

Leave a Comment
You can either do
SELECT name
FROM table2
WHERE name NOT IN
    (SELECT name 
     FROM table1)
or
SELECT name 
FROM table2 
WHERE NOT EXISTS 
    (SELECT * 
     FROM table1 
     WHERE table1.name = table2.name)
SELECT t1.name
FROM table1 t1
LEFT JOIN table2 t2 ON t2.name = t1.name
WHERE t2.name IS NULL

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.