[ACCEPTED]-MySQL IN() for two value/array?-mysql

Accepted answer
Score: 54
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:

FROM    foo
WHERE   ROW(column1, column2) IN (ROW('foo', 1), ROW('bar', 2))

I'm 1 used to the former one, though :)

Score: 3

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.

Score: 0

Great answers from @Quassnoi and @KM !!!

Also, you 2 can get pairs duplicates and select them 1 for post-processing:

FROM `foo`
WHERE (`id_obj` , `Foo_obj`)
IN (
  SELECT `id_obj` , `Foo_obj`
  FROM `foo`
  GROUP BY `id_obj` , `Foo_obj`
  HAVING count(*) > 1

More Related questions