10

I want to query a column in my table using a LIKE condition and this works fine-

select * from my_table where my_column LIKE '%hello%';

But, how do I query this column with multiple strings in my LIKE condition? Looking for something like-

select * from my_table where my_column LIKE ['%hello%'|'example%'|'%random%'|'%demo'];
kev
  • 2,741
  • 5
  • 22
  • 48

1 Answers1

18

Use regexp_like():

select *
from my_table
where regexp_like(my_column, 'hello|example|random|demo');
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Does `regexp_like()` perform as quickly as multiple `LIKE` statements? – Stevoisiak Apr 28 '22 at 19:50
  • @Stevoisiak … I would expect it to be a wee bit faster. There is only one function call versus a call for each pattern. However, it is worth testing on your database. – Gordon Linoff Apr 29 '22 at 20:09