Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    4

    Cool Unanswered: Sql Like Wildcard char %

    Simply, I've got ItemDescription field.
    I want to search for '%' anywhere in the field.
    How do I specify % inside two % symbols?

    where ItemDescription like '%%%' doesn't work.
    where ItemDescription like '%\%%' doesn't work either.

  2. #2
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208

    Re: Sql Like Wildcard char %

    Not sure how you would do that. But you can use the Instr function to determine if the character exists in the string.

    ie
    Code:
    Select *
    from (select 'd%f' col1 from dual
          union
    	  select 'stv' col1 from dual)
    where instr(col1,'%') <> 0
    Returns

    d%f

    HIH

  3. #3
    Join Date
    Jul 2003
    Posts
    2,296
    my book says that you need to specify the escape character in your query.

    so:
    Code:
    select ename
    from emp
    where ename like '_\%_' ESCAPE = '\\';
    or
    Code:
    where ItemDescription like '%\%%' ESCAPE = '\\'
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  4. #4
    Join Date
    Dec 2003
    Posts
    4
    Thanks, I'll try these suggestions out!

  5. #5
    Join Date
    Dec 2003
    Posts
    4

    Thumbs up

    Originally posted by unicoder
    Thanks, I'll try these suggestions out!
    Thanks, It works the actual syntax is ESCAPE '\' ( No Equal Sign ) added to the bottom of the query string. I can do a replace on the field ( in vb ) before it get's into the sql string to add the escape char.

  6. #6
    Join Date
    Dec 2003
    Posts
    4
    escape '\'

    hmmm... the posting system is eating the special character.

    the syntax that worked is: escape space apost backslash apost

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •