?
Solved

Escape character _ in SQL doesn't work

Posted on 2005-05-03
4
Medium Priority
?
762 Views
Last Modified: 2010-05-18
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 '%_%'
0
Comment
Question by:NicksonKoh
4 Comments
 
LVL 1

Accepted Solution

by:
Plaban_Patra earned 240 total points
ID: 13923673
'_','%' are are wild cheracters.Oracle uses them for searching when u use like .
use this..
select * from tab where instr(tname,'_')>0;
0
 
LVL 17

Author Comment

by:NicksonKoh
ID: 13923747
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
 
LVL 2

Assisted Solution

by:larowlan
larowlan earned 260 total points
ID: 13923832
try select * from tab where tname like '%\_%' escape '\'
0
 
LVL 5

Expert Comment

by:helpneed
ID: 13924052
hi

try this

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

regards
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question