问题描述
问:
我有以下情况:
的字母(等级)
A,A +,A-,B,B +,B-存储为字符串
数据库我想订购这些
等级逻辑由小
一到大的,,但这不
在实际发生什么..因为这些
都是字符串的顺序是:
set of letters (grades) A,A+,A-,B,B+,B- stored as strings in the database i wanna to order these grades logically from the small one to the big one ,, but this not what happen in real.. because these are strings the order is:
A,A +,A-我想
A,A+,A- i wanna
ASC
A-,A,A +
DESC
A +,A,A -
A+,A,A-
我绑定的成绩在下拉列表
我想这些成绩与此
在它的逻辑顺序。
i bind those grades in drop down list and i wanna these grades with this logical order in it..
有任何想法如何做
这样的..
is there any idea how to do something like this..
推荐答案
请单独的表,其中列出的档次和什么样的顺序,他们应该去:
Keep a separate table which lists the grades and what order they should go in:
Grade | SortOrder
B- | 20
B | 30
B+ | 40
A- | 50
A | 60
A+ | 70
那么你的选择查询可以做一个 INNER JOIN
此表和 ORDER BY SortOrder的
。
这篇关于如何订购逻辑串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!