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
  • 47,993
  • 9
  • 26
  • 51

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,198,228
  • 53
  • 572
  • 709
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
  • 34,995
  • 4
  • 9
  • 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%';

Ersin Gülbahar
  • 6,713
  • 15
  • 60
  • 114