MySQL checking value is not default value
is开发者_开发问答 there a 'handy' way to check whether a column value has been changed in mySQL? I presume it will need to check against the default value of the column.
thanks.
You could use MySQL TIMESTAMP and ON UPDATE to update a timstamp column when a row is updated.
The DDL would go something like this:
last_update TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
Now you can know if a row was changed by looking at last_update - and as a bonus, you can now also know when it was changed.
精彩评论