Way to compare 2 Tables data using SQL statement

Sometime we just need to compare left and right table to ensure the data are tally. There’s 2 SQL statement we can use to achieve this.

Example 1

SELECT table1.ID
FROM table1
WHERE table1.ID NOT IN(SELECT table2.ID FROM table2)

Example 2

SELECT table1.ID
FROM table1
LEFT OUTER JOIN table2 ON table1.ID = table2.ID
WHERE table2.ID IS NULL
Tagged: Tags:

Leave A Comment?