1) why autoincrement is not working for varchar in phpmyadmin?
2)can we set two autoincrement in a table in phpmyadmin?

  1. Because, you cannot increment a character.
  2. There can only be one auto increment column.
Member Avatar

diafol

Before asking if it is possible, perhaps you should ask why you're doing it. These are not common requests, so that should tell you that it's probably the wrong approach. Incrementing a character-based field is certainly possible, but again, why would you want to do it? If you need to create a custom 'id' - purely 'visual' for the use of screen or reports, then you can store an id as an autoincrement and create conversion functions. However, what a palaver.

An autoincrement is used to give a table row "uniqueness" and provide a "hook" in order to relate that row of data to another set of data in another table, why would you want two "uniquenesses"? BTW - there are other uses for autoincs, but those are the ones that usually come to the fore.

Some table types allow setting an autoinc field to a secondary field within a compound index (see the link from pritaeas), and this may be useful for you. BUT not all table types allow this - InnoDB, the new default type, does not AFAIK.

commented: good explanation +12