0

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?

William Robertson
  • 15,273
  • 4
  • 38
  • 44
cdm
  • 1
  • 1
  • 1
    https://stackoverflow.com/questions/5391069/case-insensitive-searching-in-oracle – Honeyboy Wilson Jul 28 '20 at 16:11
  • Are the three possible entries always upper/lower/mixed case variations of the same text? If the three strings are `''%INSERT%'`, `%'Insert%'` and `'%Kittens!%'`, that makes a difference. – William Robertson Jul 28 '20 at 22:49

1 Answers1

2

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

William Robertson
  • 15,273
  • 4
  • 38
  • 44