Link to home
Start Free TrialLog in
Avatar of NicksonKoh
NicksonKohFlag for Singapore

asked on

Escape character _ in SQL doesn't work

I want to list tables that contains _ but it list all the tables instead with the following sql. Why?

select * from tab where tname like '%_%'
ASKER CERTIFIED SOLUTION
Avatar of Plaban_Patra
Plaban_Patra

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NicksonKoh

ASKER

This SQL works but how would I use the escape character in such a case?

select * from tab where tname like '%\_%'

I tried the above and it does not work.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of helpneed
helpneed

hi

try this

select tname from tab where tname LIKE '%!_%' escape '!'

regards