Web Analytics Made Easy -
StatCounter update int field that is null - CodingForum

Announcement

Collapse
No announcement yet.

update int field that is null

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • update int field that is null

    Code:
    Update table set field= field+1 where id = '74'
    Field is type INTEGER
    if initial field = null --> no error , no update.

    Any comment on that
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Take a look at the MySQL page entitled "problems with NULL values".

    Basically, any expression with a NULL value ends with a NULL value. In your case, you state that the field is NULL when you start the UPDATE. Adding any value to a NULL is NULL. Thus, the field is technically updating, it's just staying NULL. Make sense?

    Comment


    • #3
      There is, however, an easy fix:
      Code:
      UPDATE table SET field = IFNULL(field,0) + 1 WHERE id = '74';
      Be yourself. No one else is as qualified.

      Comment

      Working...
      X