Escape character _ in SQL doesn't work

Posted on 2005-05-03
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 '%_%'
Question by:NicksonKoh
    LVL 1

    Accepted Solution

    '_','%' are are wild cheracters.Oracle uses them for searching when u use like .
    use this..
    select * from tab where instr(tname,'_')>0;
    LVL 17

    Author Comment

    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.
    LVL 2

    Assisted Solution

    try select * from tab where tname like '%\_%' escape '\'
    LVL 5

    Expert Comment


    try this

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


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
    I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
    This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
    This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now