multiple auto increment in mysql

前端 未结 5 1584
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条回答
  •  离开以前
    2020-12-04 02:48

    You can leave your sort column equal to NULL by default. The only thing you need is a little smarter query. For instance:

    select * 
    from something
    order by ifnull(sort, id)
    

提交回复
热议问题