There is a table with this structure:

id - AUTO_INCREMENT

name - varchar (UNIQUE)

Adding a new record to the table is performed by code:

mysql_query("INSERT INTO `table` (`name`) values ($name)"); 

If the same $ name values ​​are encountered, the entry is not added, the order is with this.

But the entries in the table look like this:

ID - name

1 - Igor

3 - Masha

6 - Vita

7 dima

10 - Viktor

That is, ID jumps for some reason ... How to avoid it?

  • 2
    Avoid - no way. Why - well, so it is (to ensure the numbering without the need to lock the table). Leave as is and do not pay attention - Mike
  • @Denis, your case - Dred
  • So, if you just check the presence of the name in the database and do not give the INSERT command? - Dodik pm
  • @Dodik is already an additional query to the database ... load ... - iKey
  • Do you need numbers in order for aesthetic pleasure? - teran 1:09 pm

0