multiple auto increment in mysql

前端 未结 5 1602
Happy的楠姐
Happy的楠姐 2020-12-04 01:56

I\'m using php and mysql. I have a table with the id column set to auto increment as the primary key. I\'m trying to add another column called sort_order. The sort_order col

5条回答
  •  萌比男神i
    2020-12-04 02:35

    You can use a trigger to update your row upon insert, or choose an appropriate value in your PHP code at the time the query is produced.

    However, you should consider whether you really need to create an auto-incrementing sort_order value. In your display code, you can sort items that have been given an explicit sort order, and place the remaining unsorted items at the appropriate place (bottom?) in the list.

提交回复
热议问题