我想以特定的方式订购我的桌子。
MYTABLE
第1列不同的值:
completed,in-progress,yetstart,yetfinish
我想通过
订购yetstart,in-progress,completed,yetfinish
按此顺序
答案 0 :(得分:3)
将FIELD()功能用于 ORDER BY 列数据:
试试这个:
SELECT *
FROM tableA
ORDER BY FIELD(column1, 'yetstart', 'in-progress', 'completed', 'yetfinish');
答案 1 :(得分:0)
select * from your_table
order by case when your_column = 'yetstart' then 1
when your_column = 'in-progress' then 2
when your_column = 'completed' then 3
when your_column = 'yetfinish' then 4
else 5
end
答案 2 :(得分:0)
SELECT * FROM table_name
ORDER BY field_name1 DESC, field_name2 DESC;