cdm
cdm

Reputation: 1

Pattern Matching with multiple possibilities sql

I am trying to match a string against one of three possible entries. Right now I have

select * from table x 
where column1 like '%INSERT%' 
or column1 like '%Insert%' 
or column1 like '%insert%';

I'm wondering if there is a more efficient way to do this, maybe using 'in' and 'like' in conjunction?

Upvotes: 0

Views: 43

Answers (1)

William Robertson
William Robertson

Reputation: 16001

From Oracle 12.2 (CI is case-insensitive, AI is accent-insensitive as well as case-insensitive):

where column1 collate binary_ci like '%insert%'

Earlier

where regexp_like(column1, 'insert', 'i')

or

where upper(column1) like '%INSERT%'

Documentation: Oracle Database 19c Linguistic Sorting and Matching

Upvotes: 2

Related Questions