0

I need to do multiple LIKEs .

I have the following code

select * from product where product_code LIKE IN ('MS%','TS%')

However I am getting the following error

ORA-00936: missing expression 00936. 00000 - "missing expression"

Am I using the correct syntax?

Thanks

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55

3 Answers3

3

You can use OR:

select * 
from product
where product_code like 'MS%' or
      product_code like 'TS%';

Or you can use regular expressions:

where regexp_like(product_code, '^(MS|TS)')
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
2

It is not possible in Oracle to use LIKE and IN together.

You must have to write Multiple LIKE and use OR as follows:

select * from product 
where (product_code LIKE 'MS%' 
   OR product_code LIKE 'TS%');
Popeye
  • 35,427
  • 4
  • 10
  • 31
0

You can also use union

select * from product where product_code like 'MS%' Union all select * from product where product_code like 'TS%';

CompEng
  • 7,161
  • 16
  • 68
  • 122