select name from users where name like '%\_%';

i am totally stunned.

i know that "_" stands for exact one char so that if i want look for "_" i have to escape it.

but why don't i get the answer i expect?

i have user like


this is what i expect to get from:
select name from users where name like '%\_%';

but i get empty result on oracle 9ir2 patchlevel 7

please help
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mightyoneAuthor Commented:
ahh i found out....

oracle needs to be told to escape \

select name from users where name like '%\_%' ESCAPE '\';
An alternative to that,

select u1 from (select 'user1' u1 from dual)
where instr(u1,'_') >0
if I didn't understand wrong,

that ur trying to search user_
and then only 1 character after that at end, correct

if this is the case then u can try:

where .... like 'user\__'
where .... like 'user__'

try & update, if this works.

cheers ;-)
mightyoneAuthor Commented:

could you explain what your query does?
specially what does (select 'user1' u1 from dual)
exactly do. it writes sth in variable u1 but what?


no, I use ora9ir2 and looked for names with underscores but got unexpected results even though i escaped the _ with \
in fact the query i use is far morcomplicated but the prob could be taken down to this point.
awking00Information Technology SpecialistCommented:
select name from users where instr(name,chr(95)) > 0;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.