Reputation: 295
I have a simple table with a few values and a primary key that is auto_incremented from 1:
create table test1 (acounter int not null primary key, studentid int not null,
ranking int not null, aweek date not null);
alter table test1 auto_increment=1;
If I were able to I could INSERT INTO test1 (NULL,1012,1,'2015-04-20')
, but the data comes in a different order so I tried INSERT INTO test1 (acounter,aweek,ranking,studentid) VALUES (NULL,'2015-04-20',1,1012)
- receive an error that the primary key cannot be NULL. I don't want it to be - I expect the auto_increment to use the next value.
Upvotes: 0
Views: 53
Reputation: 393
When you declared a column as auto increment ,Db will take of it as you insert the other values to the table.
INSERT INTO test1 (aweek,ranking,studentid) VALUES
('2015-04-20',1,1012)
Upvotes: 1