Updating by @Cesar‘s request. Hope I understood what you want, if not, please revert. Quassnoi.
If I make an SQL query like this: SELECT * FROM TABLE_NAME WHERE b IN (2, 7) AND c IN (3, 9), can I assume that MySQL will match only pairs from elements with same number in each list?
That is, (2, 3), (7, 9), …?
For example, suppose we have a table like this:
+----------+----------+----------+ | PK | b | c | +----------+----------+----------+ | 1 | 2 | 3 | +----------+----------+----------+ | 2 | 5 | 4 | +----------+----------+----------+ | 3 | 7 | 9 | +----------+----------+----------+ | 4 | 7 | 4 | +----------+----------+----------+ | 5 | 2 | 9 | +----------+----------+----------+
Is it correct to assume that the only rows returned are 1 and 3 (and not 5)?
This query will return rows, where
bis either5or7, ANDcis4.What do you mean by “evaluation in pairs?”
Update:
I’ll add one more row to the sample:
If you want to match the whole sets, you can use this syntax:
This means: “return all rows where
bis2andcis3at the same time, ORbis7andсis9at the same time.”In the example above, this query will return rows
1and3But if you rewrite this query the other way around, like this:
, this will mean “return all rows where
bis either2or7, ANDcis either3or9).This will return rows
1,3and5, since row5satisfies the condition for the second query but not for the first one.