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 '%_%'
LVL 17
NicksonKohAsked:
Who is Participating?
 
Plaban_PatraConnect With a Mentor Commented:
'_','%' are are wild cheracters.Oracle uses them for searching when u use like .
use this..
select * from tab where instr(tname,'_')>0;
0
 
NicksonKohAuthor Commented:
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.
0
 
larowlanConnect With a Mentor Commented:
try select * from tab where tname like '%\_%' escape '\'
0
 
helpneedCommented:
hi

try this

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

regards
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.