mysql表id字段属性设置为tinyint和AUTO_INCREMENT,就插入一个什么值可以令它的值自动增长1?

在插入字符串insert into 表 values()中插入insert into 表 values(‘’)和insert into 表 values(NULL)都不成,出现错误提示:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1。()里应该用什么?

第1个回答  2013-12-06
如果你在insert into table 后面没有指明要插入哪些字段,那么你在values里就要为所有字段写值,包括id. 如果你在table 后面指明要插入的字段了,这里可以只为你写的字段赋值,如果没写id的话,id 就是自增的
比如你的表有两个字段id, name.那么上两种情况分别是这样:
insert into table values (1,'张三');
insert into table (name) values ('张三');
第2个回答  2013-12-06
不写自增列就可以了
如 insert into table1(其它字段1,其它字段2,....) values(......)
或 insert into table1 其它字段1=...., 其它字段2=...., .......
没有其它字段时,也可写成 insert into table1() values()
第3个回答  2013-12-06
AUTO_INCREMENT
这就是id自增长,是你的 插入语句不对,按表字段插入追问

应该插入NULL

相似回答