Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个表,其中有列 days('mon','tue','wed','thu','fri'),我如何实现星期顺序(而不是字典顺序)到他们?
例如。
'mon'<'tue' //produce true 'fri'>'wed' //true 'fri'<'thu' //false
提前致谢!
不是你想要的方式:
ORDER BY CASE day WHEN 'mon' THEN 1 WHEN 'tue' THEN 2 ... WHEN 'sun' THEN 7 END
编辑:您还可以创建第二个表:
day_name day_order ======== ========= mon 1 tue 2 ... sun 7
... 并在选择时加入和排序。
最后但同样重要的是,将天数存储为数字 :)