Tuesday, December 16, 2008

Compare two tables, find rows existed in table 2, but not existed in table 1


-- this script would find the rows existed in table 2, but not existed in table 1
SELECT mm.id,mm.name,mm.email
FROM table2 mm
WHERE NOT EXISTS
(
SELECT 1 FROM table m
WHERE m.ID=mm.ID
And m.name=mm.name
And m.email=mm.email
)

No comments: