Reputation: 3209
Hey ya'll I have this insert statement here
INSERT INTO persons VALUES (16,'First Name',NULL,NULL,NULL,2,0,now(),NULL,NULL);
it says that the number of columns do not match because the last column is for the id which is auto incremented. do I have to put in an id value?
Thanks, J
Upvotes: 0
Views: 202
Reputation: 33
Just don't include that field INSERT INTO persons VALUES (16,'First Name',NULL,NULL,NULL,2,0,now(),NULL);
Upvotes: 0
Reputation: 17540
You should not include an Auto-increment column in your insert.
It is also best practice to put the column names after the table name. This helps to make the query cleaner and easier to read & maintain.
INSERT INTO persons(Column1, col2, ...)
VALUES (16, 'First Name', ...)
Upvotes: 4