Add a field and insert an increment value

前端 未结 2 649
执念已碎
执念已碎 2021-01-15 22:32

I have this table :

id   ref     data
1    111     data1
2    111     data2
3    111     data3
4    111     data4
5    222     data1
6    222     data2
7             


        
2条回答
  •  有刺的猬
    2021-01-15 23:02

    I believe if you create a primary key that looks like (ref, order) where order is an auto_increment, you can have have the database create this for you automatically.

    http://mysqldump.azundris.com/archives/5-AUTO_INCREMENT-Trivia.html

提交回复
热议问题