Results 1 to 3 of 3

Thread: NULL Problem

  1. #1
    Join Date
    Jan 2009
    Posts
    124

    Unanswered: NULL Problem

    I want to update a int field adding a new int(x) to the existing int(y) but y may be NULL in which case if fails. How do I write this for either case, y=int or y= NULL


    UPDATE Meet_reg_copy
    SET regFee_reg= (x + y)
    WHERE id=1

    Thanks
    Nick

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    SET regFee_reg= x + COALESCE(y,0)

    you had an unnecessary set of parentheses which i removed
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2009
    Posts
    124
    I'm old, and I forget...

    thanx

Posting Permissions

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