#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    5
    Rep Power
    0

    underscore search in oracle


    I need to search the name that contains underscore.

    The query I sent was

    select name from table where name like '%N__% ;

    and I get all the names that has single underscore too
    My output was

    N_1
    N__1
    N_1_2

    whereas I should be getting only N__1

    I understand that '_' is a special character like '%' in oracle.Difference being '_' is for single character match & '%' is for any number of characters match.

    Any help how to modify my query to get the required name only ?

    Thanks in advance.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    68
    Rep Power
    11
    Please try:

    select name from table where name like '%N\_%' ESCAPE '\';

    cheers,
    Dan
    Last edited by Dan Drillich; September 24th, 2003 at 01:01 PM.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    5
    Rep Power
    0
    Thanks. Already got it working.

IMN logo majestic logo threadwatch logo seochat tools logo