1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Single Quote Problem

Discussion in 'MySQL' started by Breakpoint, Oct 15, 2008.

  1. #1
    I have a database that stores people jobs from present and past. So the database has a field listing the job as currently (A)ctive or (I)nactive. So it could look like this

    Mike H, Janitor, I
    Mike H, Programmer, I
    Mike H, CEO, A

    A need SQL that will use a parameter called Status_Indicator which will note what the person calling the SQL would like to retrieve. The parameter can have the following in it.

    '0' = Default Value if not specified in parameter file, will return all (Acive and Inactive)
    'A' = Return only Active
    'I' = Return only Inactive
    'A','I' = Return Active and Inactive

    The code that I would like to use in the WHERE fails when testing a parameter with 'A','I'.

    Status_Indicator = '0' or
    JF.Status_Indicator in (Status_Indicator)

    and as

    'Status_Indicator' = '0' or
    JF.Status_Indicator in (Status_Indicator)

    This is because the single quotes in the parameter mess up the expressions, but I need single quotes in the expression because the database uses a CHAR.

    Could anybody tell me a way to fix this and make it work?
     
    Breakpoint, Oct 15, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    If you have values enlcosed with single quotes then this should work JF.Status_Indicator in (Status_Indicator) (in MySQL). Which database server you are using?

    Can you post your full query?
     
    mwasif, Oct 15, 2008 IP