[sql] Finding the next available id in MySQL

It's too late to answer this question now, but hope this helps someone.

@Eimantas has already given the best answer but the solution won't work if you have two or more tables by the same name under the same server.

I have slightly modified @Eimantas's answer to tackle the above problem.

select Auto_increment as id from information_schema.tables where table_name = 'table_name' and table_schema = 'database_name'