Let's say I have a table like this:
name | favorite_food |
---|---|
Mario | Burritos |
Sam | Sushi |
Cameron | Pizza |
Samantha | Burgers |
Victor | Salad |
Now let's say I want to search this table with an array of names to match people I'm looking for. That would look like this.
SELECT *
FROM favorites_table
WHERE name IN ('Sam', 'Victor', 'Cameron', 'Samantha');
Which would return:
name | favorite_food |
---|---|
Sam | Sushi |
Cameron | Pizza |
Samantha | Burgers |
Victor | Salad |
But let's say that instead of an array of exact matches, I want to match it to an array of substrings. I'm imagining combining a WHERE ... IN
clause with the LIKE
clause, something like this...?
SELECT *
FROM favorites_table
WHERE name IN LIKE ('am', 'ic');
Which would return the same results.
I know this is probably a simple task, but I'm still learning mysql, any help is appreciated <3