Answer the question
In order to leave comments, you need to log in
Is it possible to make auto_increment relative to another field?
Now the table looks like this:
`id` = 1, `id_user` = 2
`id` = 2, `id_user` = 2
`id` = 3, `id_user` = 1
`id_user` = 2, `id` = 1
`id_user` = 2, `id` = 2
`id_user` = 1, `id` = 1
Answer the question
In order to leave comments, you need to log in
myISAM only
MyISAM Notes
For MyISAM tables, you can specify AUTO_INCREMENT on a secondary column in a multiple-column index. In this case, the generated value for the AUTO_INCREMENT column is calculated as MAX(auto_increment_column) + 1 WHERE prefix=given-prefix. This is useful when you want to put data into ordered groups.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question