I have to find the next available id (if there are 5 data in database, I have to get the next available insert place which is 6) in a MySQL database. How can I do that? I h
Update 2014-12-05: I am not recommending this approach due to reasons laid out in Simon's (accepted) answer as well as Diego's comment. Please use query below at your own risk.
The shortest one i found on mysql developer site:
SELECT Auto_increment FROM information_schema.tables WHERE table_name='the_table_you_want'
mind you if you have few databases with same tables, you should specify database name as well, like so:
SELECT Auto_increment FROM information_schema.tables WHERE table_name='the_table_you_want' AND table_schema='the_database_you_want';