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

Views:
9040
Deprecated: Assigning the return value of new by reference is deprecated in /var/www/phpfreaks-site/library/StringParser/stringparser.class.php on line 982 Deprecated: Assigning the return value of new by reference is deprecated in /var/www/phpfreaks-site/library/StringParser/stringparser_bbcode.class.php on line 567 Deprecated: Assigning the return value of new by reference is deprecated in /var/www/phpfreaks-site/library/StringParser/stringparser_bbcode.class.php on line 1210 Deprecated: Assigning the return value of new by reference is deprecated in /var/www/phpfreaks-site/library/StringParser/stringparser_bbcode.class.php on line 1221 Deprecated: Assigning the return value of new by reference is deprecated in /var/www/phpfreaks-site/library/StringParser/stringparser_bbcode.class.php on line 1264 Deprecated: Assigning the return value of new by reference is deprecated in /var/www/phpfreaks-site/library/StringParser/stringparser_bbcode.class.php on line 1281 Deprecated: Assigning the return value of new by reference is deprecated in /var/www/phpfreaks-site/library/StringParser/stringparser_bbcode.class.php on line 1535

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]