Just now I needed to do something like the following query, and was surprised that it actually worked as intented. However I cannot find any documentation on it so I’m a little afraid about unknown side effects of this. Here’s what I wrote:
select * from Table1 where (col1, col2) in (select col3, col4 from Table2)
This seems to be matching a pair of columns against a list of column-pairs. Is this how it is supposed to work, or can I expect some nasty surprises down the road?
It seems there is a page in the MySQL manual about that syntax : 12.2.9.5. Row Subqueries
One of the given examples is this one (quoting) :
Which is quite similar to your query.
So I suppose it is officially supported.
The same page says (quoting) :
So, even if the syntax you proposed is valid, the second one might be better, if you can use it, at least — and more easy to read / understand 😉
And you’ll find plenty other stuff about subqueries from the page 12.2.9. Subquery Syntax
(Yeah, wasn’t easy to find ^^ )