order by charindex(字段,'aabbcc') ------其他解决方案-------------------- order by 和 where 里字段顺序一致 ------其他解决方案-------------------- order by case when 字段1='aa' then 1 end,
case when 字段2='bb' then 2 end,
case when 字段3='cc' then 3 end ------其他解决方案-------------------- LZ是说字段1 筛选出来后有个排序?还是单独abc的排序?
单独的排序,直接查询出来就是。
如果是第一种筛选后的排序,lz需要将3个部分union all
select * from TB where 字段1 = 'aa' order by x asc
union all
select * from TB where 字段2 = 'bb' order by y asc
union all
select * from TB where 字段3 = 'cc' order by z asc
------其他解决方案-------------------- where 字段1='aa' or 字段2='bb' or 字段3='cc'
order by case when 字段1='aa' then 1 when 字段2='bb' then 2 when 字段3='cc' then 3 end ------其他解决方案--------------------