sql - MySQL autoincrement tied with an attribute -


Whether to place a new ID in order to order a column, it is possible to place its own position is? Then say I have the following columns:

  ID order 1 1 1 1 2 1 3 1 4   

When I add another order order increment 5, when I insert 2 as a new ID order, starts with 0.

This example uses a composite index, but begins with number 1 < Pre> Make table test (id small-no zero, norder int unsigned fault auto_increment, primary key (id, norder)) engine = myisam; Insert the test (id) value (1), (1), (1), (2), (3), (1), (1), (4), (5), (1)

If you want it to start with zero then it has already been said that you need a trigger.

Comments