What's the best way to store sort order in SQL?

后端 未结 5 1076
栀梦
栀梦 2020-12-29 02:09

The guys at the top want sort order to be customizable in our app. So I have a table that effectively defines the data type. What is the best way to store our sort order. If

5条回答
  •  隐瞒了意图╮
    2020-12-29 02:45

    Generally the application would add the approriate ORDER BY clause to the query. If the result sets to be sorted are relatively small you can have keys on the selection criteria. Even with large results it is often better to sort the selected data than retrieve in order by index.

    If the requirement is to have orders like B A Z T Q M K, then you will need a column to place the relative order into. The appropriate value would need to be determined each time you add a row. However, this works well for code tables which are relatively static.

提交回复
热议问题