Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining LIKE with IN in SQL

Instead of executing:

SELECT a
FROM b
WHERE a LIKE 'a%'
OR a LIKE 'b%'
OR a LIKE 'c%'


is there a way to execute something functioning like this pseudocode?

SELECT a
FROM b
WHERE a IN ('a%', 'b%', 'c%')

like image 773
JonathanWolfson Avatar asked Dec 03 '22 07:12

JonathanWolfson


1 Answers

Might be too specific to your example, but you could do LIKE '[a-c]%'. Other than that, I'm not aware of any LIKE-like IN syntax

like image 91
n8wrl Avatar answered Dec 23 '22 14:12

n8wrl