我有幾個值,和從1 auto_incremented主鍵的簡單表:INSERT AUTO_INCREMENT值
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;
如果我能我能INSERT INTO test1 (NULL,1012,1,'2015-04-20')
,但數據是在一個不同的順序,以便我試過INSERT INTO test1 (acounter,aweek,ranking,studentid) VALUES (NULL,'2015-04-20',1,1012)
- 收到主鍵不能爲NULL的錯誤。我不希望它是 - 我期待auto_increment使用下一個值。
不要在語句中提供自動增量字段名稱或值。假裝它不在那裏,數據庫會照顧它。 –
你不想插入自動增量值 – Cherry
INSERT INTO test1(aweek,ranking,studentid)VALUES('2015-04-20',1,1012) – Cherry