1.比如创建一张表
create table tbl_test(id int(11) auto_increment,name varchar(22) ,primary key (id))Engine=InnoDB;
insert into tbl_test (name) values ('aaaaaaa');
select last_insert_id();
必须进入插入操作后,才能获取插入的id
2 利用shema数据库中的table表
$sql ="select auto_increment from information_schema.`TABLES` where TABLE_NAME='tbl_test'";
最后
以上就是温柔电源最近收集整理的关于MySql获取下一个自增id的方法的全部内容,更多相关MySql获取下一个自增id内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复