Reputation: 1422
I would like to reuse an AUTO INCREMENT ID that is being deleted. am using the MySQL database.
Thanks in Advance
Upvotes: 1
Views: 823
Reputation: 1079
SELECT id + 1 FROM TableName t1 WHERE NOT EXISTS (SELECT 1 FROM TableName t2 WHERE t2.id = t1.id + 1) limit 0,1
Upvotes: 2
Reputation: 1079
To find that you can use this
SELECT Auto_increment FROM information_schema.tables WHERE table_name='tableName' AND table_schema = 'dataBaseName';
Upvotes: 0