MySQL Forums
Forum List  »  Performance

Re: How to do EXCEPT with effective SQL?
Posted by: Roland Bouman
Date: August 20, 2005 05:05PM

Hi,

You could try to write it like this:

SELECT c
FROM Table1 t1
WHERE NOT EXISTS (
SELECT null
FROM Table2 t2
WHERE t1.c = t2.c
)

or like this:


SELECT c
FROM Table1 t1
LEFT JOIN Table2 t2
ON t1.c = t2.c
WHERE t2.c is null

The latter sample in particular could be quite a bit faster.

BTW i trust you do have an index for the column(s) that is (are) compared?

Good luck, and let us know what happened.

Options: ReplyQuote


Subject
Views
Written By
Posted
2495
August 20, 2005 08:42AM
Re: How to do EXCEPT with effective SQL?
1512
August 20, 2005 05:05PM
1307
August 21, 2005 07:43AM
1338
August 21, 2005 01:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.