0

I have a table called Meeting with ID auto increment

I want select query to get last auto increment id. However, I used MAX(ID) but there is an issue which is if I delete last record will not work.

anas
  • 9
  • 3
  • 1
    whats about this SELECT your_id FROM your_table ORDER BY your_id DESC LIMIT 1 ? – Ranjeet Singh Apr 14 '16 at 06:32
  • This sounds like an XY problem-what do you want the auto increment ID for? – Joni Apr 14 '16 at 06:36
  • 1
    Possible duplicate of [How to get last inserted id from table MySQL](http://stackoverflow.com/questions/20891875/how-to-get-last-inserted-id-from-table-mysql) – msp Apr 14 '16 at 06:49

1 Answers1

2

use this query:

SELECT `AUTO_INCREMENT`
FROM  INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'your_db_name'
AND   TABLE_NAME   = 'your_table_name'
ghaziksibi
  • 471
  • 3
  • 12