How to get the next auto-increment id in mysql

You can use

SELECT AUTO_INCREMENT
FROM information_schema.tables
WHERE table_name="table_name"
AND table_schema = DATABASE( ) ;

or if you do not wish to use information_schema you can use this

SHOW TABLE STATUS LIKE 'table_name'

Leave a Comment