Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Posts
    40

    Unanswered: Update statement

    Hi

    I want to add an IF clause in the update statement


    update account set
    a1 = '45',
    (Make a2 = '123' when a3=11 else make a2='222'),
    where a4='10'


    How do I do that?


    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    UPDATE	  account 
       SET          a1 = '45',
    	, a2 = CASE WHEN a3=11 THEN '123' ELSE '222' END
     WHERE	  a4='10'
    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.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    brett, my good man, stick to trailing commas, or leading commas (my preference), but not both

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply 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
  •