问题描述
- mysql数字排序问题。
-
数据库为:mysql
现有表 t_table ,字段 c_column;c_column的取值范围是1,2,3。
要求排序后的结果是:1,1,1,3,3,2,2,2,2这种结构,排序怎么写?
解决方案
没看懂你干嘛,复合查询就好了,
解决方案二:
create table tbl (
id bigint not null primary key,
fieldValue bigint not null
)
insert into tbl (id, fieldValue) values (1, 0),
(2, 4),
(3, 2),
(4, 3),
(5, 1)
select * from tbl ORDER BY fieldValue in (1,4), fieldValue
解决方案三:
select * from t_table
order by find_in_set(c_column,'1,3,2');
时间: 2024-08-24 18:13:04