mysql的骚操作:自增长的字段同时插入到另一个字段

如题

1 insert into users(username,password) values((select auto_increment from information_schema.tables where table_schema ='mytest' and table_name='users'),'123456' );
2 
3 select * from information_schema.tables where table_schema ='mytest' and table_name='users';
1 INSERT menu (id,name,url,parent_id,`order`) VALUES((select AUTO_INCREMENT from information_schema.tables where  table_name='menu'),'1','4','1',`id`);

需要AUTO_INCREMENT表的权限,其他的地方还要考虑并发问题?

SQL来源:https://blog.csdn.net/boom_man/article/details/78126972

猜你喜欢

转载自www.cnblogs.com/tuhooo/p/9239181.html