sql missing records from another table

Solutions on MaxInterview for sql missing records from another table by the best coders in the world

showing results for - "sql missing records from another table"
Nanette
17 Feb 2019
1-- Returns missing my_table1 ID in my_table2 
2SELECT DISTINCT t1.* FROM my_table t1
3LEFT OUTER JOIN my_table2 t2
4ON t1.ID = t2.ID
5WHERE t2.ID is null;
6-- Or:
7SELECT t1.* FROM my_table1 t1 WHERE NOT EXISTS 
8   (SELECT ID FROM my_table2 t2 WHERE t2.ID = t1.ID);
9-- Or:
10SELECT t1.* FROM my_table1 t1 WHERE t1.ID NOT IN 
11   (SELECT ID FROM my_table2 t2 WHERE t2.ID = t1.ID);