Whats the best way to query MySql when I want the query return all rows where at least one value in a list of values matches at least one value in a list of values?
example
If my table contains the following rows:
name groups
item1 gr1, gr2
item2 gr1,gr2,gr3
item3 gr1,gr3
And I have a list of values: "gr3,gr4,gr5"
I want to find all the rows in my table that have at least one of the values gr3,gr4 or gr5 in its groups field.
So the query in this case should return item2 and item3
How can I construct an efficient query without looping in my script?