Results 1 to 7 of 7

Thread: 'LIKE' Statement and '%'

  1. #1
    Join Date
    Jun 2003
    Location
    France
    Posts
    8

    'LIKE' Statement and '%'

    Hello Guys,

    i would to know how to make a 'like' statement with a sentence wihch could contains the '%' character.
    ie : 100 % in the sentence "100 % free"

    for instance the statement should have been :

    select * from tablename where lib like '100 %'

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    create table test112 (id int, name char(30))
    insert into test112 select 1,'100 % detail'
    insert into test112 select 1,'My detail 5 % detail'
    insert into test112 select 1,'60 % detail'
    insert into test112 select 1,'60 % detail'
    insert into test112 select 1,' My detail 17 %'

    select * from test112 where name like '%5 [%]%'
    Last edited by MAK; 07-10-2003 at 08:06 AM.

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Or you can use ESCAPE key word to denote an escape character of your choice

    select * from test112 where name like '%5 /%%' ESCAPE '/'

  4. #4
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254

  5. #5
    Join Date
    Jun 2003
    Location
    France
    Posts
    8
    Originally posted by skhanal
    Or you can use ESCAPE key word to denote an escape character of your choice

    select * from test112 where name like '%5 /%%' ESCAPE '/'
    could you please give me a sample of ESCAPE.

  6. #6
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    use the above table and run the below query

    select * from test112 where name like '100 /%%' ESCAPE '/'

    or

    select * from test112 where name like '%5 /%%' ESCAPE '/'

  7. #7
    Join Date
    Jun 2003
    Location
    France
    Posts
    8
    Thank you pal
    Have a nice end of day

Posting Permissions

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