mysql获取一个表中的下一个自增(id)值的方法
MySQL: Get next AUTO_INCREMENT value from/for table
Note to self: To get the nextauto_increment
value from a table run this query: SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = $dbName AND TABLE_NAME = $tblName
. Don’t forget it (again).给自己做笔记:从表中获取下一个自增值时只要运行以下sql语句即可:
AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = $dbName AND TABLE_NAME = $tblName;
例如:
SELECT auto_increment FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='my_db_name' AND TABLE_NAME='my_table_name';