Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the "IN" operator use LIKE-wildcards (%) in Oracle?

Tags:

I have searched this question, and found an answer in MySQL but this is one of those incidents where the statement fails to cross over into Oracle.

Can I use wildcards in "IN" MySQL statement?
pretty much sums up my question and what I would like to do, but in Oracle

I would like to find the legal equivalent of

Select * from myTable m where m.status not in ('Done%', 'Finished except%', 'In Progress%') 

Thanks for any help

like image 526
Matt Avatar asked Mar 02 '12 20:03

Matt


People also ask

Can we use like with in in Oracle?

You can also using the % wildcard multiple times within the same string. For example, SELECT last_name FROM customers WHERE last_name LIKE '%er%'; In this Oracle LIKE condition example, we are looking for all customers whose last_name contains the characters 'er'.

Can we use like in in clause?

If you want to select records in which a string matches a specific pattern, you can use a LIKE clause as the condition in a WHERE clause.

Which of the following characters can you use as wildcards in like conditions in Oracle database?

The pattern includes the following wildcard characters: % (percent) matches any string of zero or more character. _ (underscore) matches any single character.


2 Answers

Select * from myTable m where m.status not like 'Done%'  and m.status not like 'Finished except%' and m.status not like 'In Progress%' 
like image 136
CFL_Jeff Avatar answered Dec 25 '22 09:12

CFL_Jeff


It seems that you can use regexp too

WHERE NOT REGEXP_LIKE(field, '^Done|^Finished')

I'm not sure how well this will perform though ... see here

like image 34
Sebastian Piu Avatar answered Dec 25 '22 09:12

Sebastian Piu