[ACCEPTED]-MySQL IN() for two value/array?-mysql
Accepted answer
SELECT *
FROM foo
WHERE (column1, column2) IN (('foo', 1), ('bar', 2))
This syntax may be confusing, and it may 2 be more readable to replace it with:
SELECT *
FROM foo
WHERE ROW(column1, column2) IN (ROW('foo', 1), ROW('bar', 2))
I'm 1 used to the former one, though :)
If you can get your values into a temp table 4 (you only need the two columns) easily and 3 quickly, you can just INNER JOIN your way 2 there. If not, you'll have to use @Quassnoi 1 version.
Great answers from @Quassnoi and @KM !!!
Also, you 2 can get pairs duplicates and select them 1 for post-processing:
SELECT *
FROM `foo`
WHERE (`id_obj` , `Foo_obj`)
IN (
SELECT `id_obj` , `Foo_obj`
FROM `foo`
GROUP BY `id_obj` , `Foo_obj`
HAVING count(*) > 1
)
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.