Results 1 to 3 of 3

Thread: SQL query help

  1. #1
    Join Date
    Nov 2002
    Posts
    231

    SQL query help

    I need to get the all the row for the value 11 from the below table. Could give me query for this.


    create table teststring(a varchar(25))

    insert into teststring
    values('11:02,05:BL')
    insert into teststring
    values('16:03,11:RS')
    insert into teststring
    values('13:01,04:LL')
    insert into teststring
    values('16:05,11:RS')

    drop table teststring

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    Are you asking how to find rows with the value "11" in it? If so, simply use the CharIndex() function.

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    --For all 11
    select * from teststring where charindex('11',a)<>0

    --For 11 in the first two character
    select * from teststring where left(a,2)='11'

    --For 11 after comma
    select * from teststring where substring(a,7,2)='11'

Posting Permissions

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