Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SQL using Like for a wildcard

I know you can use LIKE for a select statement to search for a string and then use wildcards to match that string.. ex:

Select * from table where first_name LIKE '%r%';

Would return names such as robert, roland, craig, etc.

I'm curious how you would search for an actual wildcard in the string such as the %:

Select * from table where values LIKE '% % %';

(the middle % being what you would be looking for) (obviously this is not the correct way to do it which is why I'm asking).

like image 539
toups Avatar asked Apr 18 '12 04:04

toups


People also ask

What can I use instead of like operator Oracle?

INSTR is another option but you cannot have an index which suits this comparison. Save this answer.

Can we use like operator in if condition in Oracle?

you cannot. where name like 'sasho' or name like 'shashi%' or name like 'rags'; the LIKE operation is not permitted to be used with IN.

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

There are two wildcards often used in conjunction with the LIKE operator: The percent sign (%) represents zero, one, or multiple characters. The underscore sign (_) represents one, single character.


1 Answers

How about

LIKE '%\%%' ESCAPE '\'

http://docs.oracle.com/cd/B12037_01/server.101/b10759/conditions016.htm

like image 78
zerkms Avatar answered Sep 28 '22 17:09

zerkms