MySQL Insert NULL Inserts 0 I am using MySQL and PhpMyAdmin, I have a table named items - the structure is as follows;

+------+---------+------+---------+
| name | type    | Null | Default |
+------+---------+------+---------+
| id   | int(11) | No   | None    |
+------+---------+------+---------+
| year | int(4)  | Yes  | Null    |
+------+---------+------+---------+


Within PhpMyAdmin I run the following query;

UPDATE `item` SET `item_publication_year` = '' WHERE `item_id` = '5'


This executes successfully.

Then I run this query;

SELECT * FROM `item` WHERE `item_id` = '5'


This executes successfully and produces the following;

+-----+------+
| id  | year |
+-----+------+
| 5   | 0    |
+-----+------+


Why is the year field 0 - shouldn't it be NULL? Am I doing something wrong?
'' is an empty string, it's not a NULL value. 

Other DBMS would rightfully reject your update statement in the first place (because  it's invalid to assign a string to a number). 

If you want to set something to null then use null not an empty string

UPDATE item 
  SET item_publication_year = null 
WHERE item_id = 5




You should also use the correct literal type for the data type. '5' is a string, it's not a number . 5 is a number. Not using the correctly typed literal might result in indexes not being used.