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 [其他解释]
order by 字段1即可。
[其他解释]
这个老好了... [其他解释] 哦,不好意思,我写错了一点
应该是 where 字段1='aa' or 字段1='bb' or 字段1='cc' 是同一字段,不好意思,再帮解一下 [其他解释] 7楼 直接order by 字段1是按字段内容进行排序,并非是按 or来排序
纠正一下, where 字段1='aa' or 字段1='bb' or 字段1='cc' 是同一字段,结果想按 字段1='aa' 字段1='bb' 字段1='cc'的结果排列,谢谢大家帮忙 [其他解释]