Blog: Article on MySQL Number columns and UPDATE statements on numeric types

Views:
11270

Here's something about mysql create table definitions that can easily catch you if you aren't careful. Consider this table definition:

CREATE TABLE screenshots (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, votes INT);

What the user wanted was a simple table to keep track of user submitted screen shots. Of course the real table had a submission date, and name column but I've omitted those in order to focus on what can happen when you allow a numeric column to have NULL values.

http://www.gizmola.com/blog/archives/91-Mysql-Update-Null-+-1-is-Null!.html [http://www.gizmola.com/blog/archives/91-Mysql-Update-Null-+-1-is-Null!.html]