We help IT Professionals succeed at work.

reset mysqli id numbers

GCF1 asked
Hi I have a table with a id that increments when you add image names to it, but the problem is that if i delete a image the id numbers dont reflect that.

Ie. 123456 delete 5 leaves 1234.6
 ideally would like to leave 12345
Is there anyway or Magical keyword to reset ?
Watch Question

Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
no. auto_increment is to automatically increment on insert.
it will NOT update when you delete.

so, what you would need to do is to update all records with an id > value you currently deleted....
however, then, it's no longer an ID (in the send of primary key), and should not be a auto_number ...
Shinesh PremrajanEngineering Manager
I think its not possible to do that, since its controlled internally by mysql engine. i think the same is applied in all the database systems available in the market