MySQL (v5.41) on Ubuntu is inserting rows with primary key value as 0.
Below is the MyS开发者_Python百科QL table data.
mysql> select id from keywords where text_id = 72;
+----+
| id |
+----+
| 0 |
| 0 |
+----+
| keywords | CREATE TABLE `keywords` (
`id` int(11) NOT NULL DEFAULT '0',
`to_user_id` bigint(20) DEFAULT NULL,
`text_id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+--------+---------------------------------
set the primary key column to AUTO INCREMENT
also.
Like
CREATE TABLE table (
id INT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM;
You probably don't have the field id as AUTOINCREMENT
精彩评论