I’m working with a MySQL database and trying to simplify my query. Right now I have something that works but it’s really long and repetitive:
SELECT * FROM products p WHERE p.productName LIKE '%ABC%' OR p.productName LIKE '%DEF%' OR p.productName LIKE '%GHI%'
This gets really messy when I need to check for more patterns. I was wondering if there’s a way to combine LIKE with IN operator, something like this:
SELECT * FROM products p WHERE p.productName LIKE IN('%ABC%', '%DEF%', '%GHI%')
I’ve been searching for a solution but can’t find a direct way to do this. Is there some MySQL function or syntax I’m missing? Or maybe there’s a completely different approach I should be using for this type of pattern matching? Any help would be great!