Subscribe to PHP Freaks RSS

Article on MySQL Number columns and UPDATE statements on numeric types

Print
by gizmola on Feb 13, 2009 3:25:13 PM - 11,599 views

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

Comments

No comments have been posted.

Add Comment

Login or register to post a comment.