Empty string inserting a zero, not a null
问题 My insert statement looks like this: INSERT INTO foo (bar) VALUES (''); The bar field was created like so: bar INT(11) COLLATION: (NULL) NULL: YES DEFAULT: (NULL) MySQL version: 5.1. Shouldn’t an empty string insert a NULL? I’m not sure why I’m seeing a zero (0) being stored in the table. 回答1: MySQL by default attempts to coerce invalid values for a column to the correct type. Here, the empty string '' is of type string, which is neither an integer nor NULL. I suggest taking the following