Quantcast
Viewing latest article 6
Browse Latest Browse All 17

Check value exist in a table but not in another table

SQL to check a value exist in one table but not in another.

SELECT t1.name
FROM table1 t1
LEFT JOIN table2 t2 ON t2.name = t1.name
WHERE t2.name IS NULL

or this (not tested)

SELECT *
FROM   B
WHERE  NOT EXISTS (SELECT 1 
                   FROM   A 
                   WHERE  A.ID = B.ID)

Viewing latest article 6
Browse Latest Browse All 17

Trending Articles