Quantcast
Channel: database – blog.azwan.net
Viewing all articles
Browse latest Browse all 16

Check value exist in a table but not in another table

$
0
0

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 all articles
Browse latest Browse all 16

Trending Articles