>>SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2)
>>SELECT * FROM table2 WHERE id NOT IN (SELECT id FROM table1)

Yes, and may be UNION the two in one:
SELECT id FROM table1 WHERE id NOT IN (SELECT id FROM table2)
UNION
SELECT id FROM table2 WHERE id NOT IN (SELECT id FROM table1)

However, if the tables are big tables, this might kill the server, so may be using
LEFT JOINs could be more efficient in this case:

SELECT table1.id FROM table1 LEFT JOIN table2 ON table1.id = table2.id
WHERE table2.id IS NULL

I didn't test it, but this should select records in table1 that have no match in table2
Then invert the quey for the othe table.

--
_______________________________________
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to