SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can i get this SQL statement to remove apostrophes

    Hey everyone,

    I have the following SQL statement:

    Code:
    SELECT	Out.ID 
    FROM	Quote Inc 
    INNER JOIN Quote Out ON Inc.Code = Out.Code 
    WHERE Inc.ID IN (@TourIDString) AND Inc.ID <> Out.ID
    @TourIDString contains values like so:

    '89918, 89641, 89644, 89668, 89649'
    So when putting this into context, the SQL Statement in return would be this:

    Code:
    SELECT	Out.ID 
    FROM	Quote Inc 
    INNER JOIN Quote Out ON Inc.Code = Out.Code 
    WHERE Inc.ID IN ('89918, 89641, 89644, 89668, 89649') AND Inc.ID <> Out.ID
    My question is, that is there any way or removing the apostrophes so that i am returned with this:

    Code:
    SELECT	Out.ID 
    FROM	Quote Inc 
    INNER JOIN Quote Out ON Inc.Code = Out.Code 
    WHERE Inc.ID IN (89918, 89641, 89644, 89668, 89649) AND Inc.ID <> Out.ID
    Hope someone can help me out?

    Kind regards,
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by billy_111 View Post
    My question is, that is there any way or removing the apostrophes
    do that with whatever application language you're using

    it's not a problem for sql, it's a problem in constructing the proper query string before you execute it
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    should it not be

    Code:
    '89918','89641','89644','89668','89649'
    ?

    That's the only way I have got an array to work correctly in that usage. (maybe it's a perl thang).

    bazz

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    no it shouldn't, it's a numeric column
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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