W
W
wwspb2017-03-09 12:56:55
MySQL
wwspb, 2017-03-09 12:56:55

Is it possible to use WHERE IN in MySQL queries with a set of fields?

It is necessary to select all records from the table by the value of 2 fields included in a certain set of values.
Is it possible to use WHERE IN in a similar way:
SELECT *
FROM table
WHERE (id, name) IN ((value11, value12), (value21, value22), (value31, value32))
I did not come across a similar description of this conditional operator in any docks . MySQL queries will be executed, but Doctrine swears at such use, which caused a lot of doubts about the validity of such queries.
Can you please tell me if these requests are correct? Can anyone come across a description of such a use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
d-stream, 2017-03-09
@d-stream

Isn't it easier to do a left join ?

D
Draconian, 2017-03-09
@Draconian

In my opinion, this is not a valid query, according to the SQL standard.
Why not filter id and name separately?
Those.:

SELECT * 
FROM table
WHERE id in (...) AND name in (...);

Why do you need such pairs to use?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question