Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to search text for an underscore '_' character?

Status
Not open for further replies.

kjnorman

Technical User
Jun 16, 2003
11
US
Okay I feel pretty stupid right at this moment, as I feel that this should be an easy answer but here I go.

I want to search a text field and return rows where there is an underscore '_' in the text. The problem is, is that the underscore is a single character wildcard as you all well know.

Currently I translate the searched text this way:

translate(my_searched_field,'_','~') like '%~%'

and it works, but is there a better way?

Thanks.
 
I believe so:
Code:
...WHERE my_searched_field like '%#_%' escape '#';
You can use any character you like for the escapte character. (But you probably don't want to use the "_" and "%" characters [smile].)

Let us know how you like this method.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
or perhaps:
Code:
WHERE instr(my_searched_field,'_') > 0

[sup]Beware of false knowledge; it is more dangerous than ignorance.[/sup][sup] ~George Bernard Shaw[/sup]
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top