Anil
Anil

Reputation: 603

SQL query to return all records that has % in it

I have a table image with columns id (number), url (varchar2(200)).

Now I want to write a query to find all the urls which have character in it'%'. Does anyone how to write query for this?

Upvotes: 2

Views: 63

Answers (3)

Brian Leach
Brian Leach

Reputation: 2101

Already answered, I'll throw my two cents in for another alternative:

where instr(url, '%') > 0

Upvotes: 1

kyle
kyle

Reputation: 2638

You can use 'LIKE' to search for a character in the URL field. The gotcha is that the percent is used as a wildcard when doing a string comparison. Do get around that functionality you need to escape the percent sign.

WHERE url LIKE '%\%%';

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1270361

One method uses like:

where url like '%$%%' escape '$'

Upvotes: 3

Related Questions