Results 1 to 6 of 6

Thread: In Clause

  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Unhappy Unanswered: In Clause

    when I do a simple select statement such as this:
    select Idnum from booktable where bookname in ('lee's boots','text')

    it don't work because there already is a single quote in the text (lee's boots)...

    is there another way to approach this?

    I used double quotes but that don't work either...

    thank..

  2. #2
    Join Date
    Sep 2003
    Location
    Dallas, Texas
    Posts
    311

    Re: In Clause

    Try this,

    select Idnum from booktable where bookname in ('lee''s boots','text')

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    149

    Re: In Clause

    If you know that data values then try

    select Idnum from booktable where bookname in ('lee''s boots','text')

    If not you might have to write a function to replace all the ' with '' in your searched column.

    - CB




    Originally posted by choco
    when I do a simple select statement such as this:
    select Idnum from booktable where bookname in ('lee's boots','text')

    it don't work because there already is a single quote in the text (lee's boots)...

    is there another way to approach this?

    I used double quotes but that don't work either...

    thank..

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    DECLARE @x varchar(25)
    SELECT @x = 'lee'+''''+'s boots'
    SELECT @x
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Sep 2002
    Location
    Mancos, CO
    Posts
    73

    Re: In Clause

    Originally posted by choco
    when I do a simple select statement such as this:
    select Idnum from booktable where bookname in ('lee's boots','text')

    it don't work because there already is a single quote in the text (lee's boots)...

    is there another way to approach this?

    I used double quotes but that don't work either...

    thank..
    Try putting an extra single quote in your criteria string

    Select Idnum from booktable where bookname In('lee''s boots','text')

    This worked on some dummy data I drummed up.

    Brent

  6. #6
    Join Date
    Nov 2003
    Posts
    2

    Re: In Clause

    Originally posted by baolive
    Try putting an extra single quote in your criteria string

    Select Idnum from booktable where bookname In('lee''s boots','text')

    This worked on some dummy data I drummed up.

    Brent
    You guys are awsome!

    This worked!

    Thank you very much! Always learning something new in SQL!

Posting Permissions

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