MySQL IN() for two value/array? -


I have a problem finding a better way to find MySQL for a pair of values ​​in a table. Values ​​are added to an array, and want to duplicate the IN () function, but for more than 1 value.

For example, purposed; I have added the following 3:

  foo, 1 boo, 2 goo, 3  

The current solution says here:

  SELECT * FROM [table] WHERE (column 1 = 'FU' and column 2 = 1) or (column1 = 'boo' and column 2 = 2) or (column 1 = 'goo' and column 2 = 3);  

I think there is another "sexy" solution that I could have as many hundred pairs and it could be that the O.S. Thanks!

  Foo WHERE (column1, column2) IN (('This syntax is misleading) , And it can be more readable to replace it with:  
   

Code> SELECT * Foo WHERE ROW (column1, column2 ) IN (ROW ('foo', 1), ROW ('bar', 2))

former one, though :)


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -