Syntex Error, Update Multi - colomns - multi feilds in one query .

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Scorp Scorp
    New Member
    • Mar 2011
    • 40

    Syntex Error, Update Multi - colomns - multi feilds in one query .

    Dear All,
    Hope every thing going fine...

    Am trying to run this query , but am getting :
    Syntex Erro (missing operator) in query expression 'CASE code .....

    My querys is :
    Code:
    Update tb_details
    set quantity = CASE code 
    when 8668 then "2"
    when 8669 then "3"
    when 8670 then "0" 
    when 8671 then "2"
    END
    where 
    code   IN (8668, 8669, 8670, 8671) ;
    where Qunatity is a string value and code is an automatic number .
    Access 2007, Sql view

    P.S.: i aslo tried for feild other than the code feild , since it could be a Key-word, error still exist
    Any Ideas ...
    Thnaks in advance
    Last edited by Scorp Scorp; Apr 12 '11, 10:39 AM. Reason: more expla.
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1288

    #2
    Is this in the right forum? Looks like maybe it should be in the SQL forum.

    jim

    Comment

    • gershwyn
      New Member
      • Feb 2010
      • 122

      #3
      Access does not support the SQL you are trying to use here. The closest equivalent would be to use the Switch function.
      Code:
      SET quantity = Switch(Code = 8668, "2", Code = 8669, "3")
      Though personally, I'd prefer to create a table that cross references the code to the quantity, and use a join to lookup the values. That way any changes or additions could be made directly to the table without increasing the complexity of the SQL statement.

      Comment

      • Scorp Scorp
        New Member
        • Mar 2011
        • 40

        #4
        Hey gershwyn thanks for the note Access does not support the SQL you are trying to use here. I didnt know !!!

        I'll try to use your statmnt ...

        Thanks .

        Comment

        • Scorp Scorp
          New Member
          • Mar 2011
          • 40

          #5
          Thanks gershwyn , your statmnt worked just fine, did what it supposed to do :) , thanks a lot

          Regards,

          Comment

          Working...