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.
我有一个“顺序”列,我在其中存储文章,然后以特定顺序显示它们。我使用枚举类型'0','1','2','3',默认为0。我需要一个查询来对结果进行排序:1、2、3、0、0、0、0 等等,以零为单位。是否可以?
试试这个:
select * from table order by val = '0', val
即使您稍后将新值添加到枚举中,这也将起作用。
试试这个
select ... from ... order by case `order` when 0 then 4 else `order` end asc