Suppose I have this array:
$city = ["toronto", "chicago", "potato"];
and my table looks like this:
Table Name: city_table
id city
1 toronto, orlando
2 buffalo, toledo
3 orlando, tomato
4 potato, chicago, nanaimo
Is it possible to have a query that gives me this result?
id city
1 toronto, orlando
4 potato, chicago, nanaimo
I tried this but it obviously doesn't work:
$city_string = "'toronto', 'chicago', 'potato'";
SELECT * from city_table WHERE city IN $city_string
IN, you could useFIND_IN_SETas the answers below suggest, but I am pretty sure it would ignore the benefits of any indexes...actually neither will work, as @Barmar pointed out, youcityfield is loaded with CSVs as well...you're effectively looking for intersecting arrays, with neither array represented effectively.