sql values not in another table

Solutions on MaxInterview for sql values not in another table by the best coders in the world

showing results for - "sql values not in another table"
Pia
16 Jun 2020
1-- Find missing t1 values in t2 (based on 'id' field)
2SELECT * FROM t1 WHERE t1.id NOT IN (SELECT id FROM t2);
3-- or
4SELECT * FROM t1 WHERE NOT exists (
5    SELECT NULL FROM t2 WHERE t2.id = t1.id
6);
7-- or
8SELECT t1.* FROM t1 LEFT OUTER JOIN t2 ON t2.id = t1.id WHERE t2.id IS NULL;