sql find missing values between two tables

Solutions on MaxInterview for sql find missing values between two tables by the best coders in the world

showing results for - "sql find missing values between two tables"
Alexander
26 Jan 2020
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);