MySQL Forums
Forum List  »  Newbie

Re: WHERE (col1 AND col2) IN ((1 AND 6), (3 AND 4), (5 AND 5))??
Posted by: morgan
Date: March 17, 2005 12:29AM

I think I found the answer to my own question...

http://dev.mysql.com/doc/mysql/en/optimizing-subqueries.html

---------------

Use a row subquery instead of a correlated subquery. For example, use this query:

SELECT * FROM t1
WHERE (column1,column2) IN (SELECT column1,column2 FROM t2);

Instead of this query:

SELECT * FROM t1
WHERE EXISTS (SELECT * FROM t2 WHERE t2.column1=t1.column1
AND t2.column2=t1.column2);

---------------

So the syntax is simply:
WHERE (col1, col2) IN ((1, 6), (3, 4), (5, 5)).

At least I think so... I haven't tested it thoroughly yet.

Options: ReplyQuote


Subject
Written By
Posted
Re: WHERE (col1 AND col2) IN ((1 AND 6), (3 AND 4), (5 AND 5))??
March 17, 2005 12:29AM


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.