Since your primary key field haven’t set as auto-increase, if an insert SQL would insert a record with no id value (default would insert value 0), it causes error.
Solution:
ALTER TABLE your_table_name MODIFY COLUMN your_column dataType AUTO_INCREMENT ;use my case be an example:
ALTER TABLE tbl_section MODIFY COLUMN id INT(11) NOT NULL AUTO_INCREMENT ;
Reference:
http://stackoverflow.com/questions/2169080/mysql-alter-a-column-to-be-auto-increment
No comments :
Post a Comment