1

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

Alec Mather
  • 742
  • 5
  • 20
  • It is not clear enough it is for it is for mysql, or if you typed mysql as a mistake. – sergiol Mar 04 '21 at 23:56
  • Sorry I should have been more specific, I'm using Postgres, and this answered my question perfectly https://stackoverflow.com/a/52264937/10637188 – Alec Mather Mar 05 '21 at 00:08

0 Answers0