mysql 按特定城市优先排序,然后按省份的中文字母排序,然后按城市的中文字母排序 示例。

 select a.id,
               a.name,          
               ac.name AS categoryName,
               a.province ,
               a.city,
               a.legal_representative AS legalRepresentative,
               a.registration_date AS registrationDate
        from
            xxxx_xxxxx a
        left join
            xxxxxxxxx_cccccccc ac on a.category_id = ac.id
        where a.audit_status = 1
        order by
            if (a.id in (select ast.association_id from ccccc_cccccc  ast where ast.status =1 order by ast.sort_num asc) ,0,1),
            case
                when a.city ='深圳市' then 0
                when a.city ='广州市' then 1
                when a.province ='北京' then 2
                when a.province ='上海' then 3
                when a.city ='杭州市' then 4
                when a.city ='武汉市' then 5
                when a.city ='成都市' then 6
                when a.province ='重庆' then 7
                when a.city ='南京市' then 8
                when a.province ='天津' then 9
                when a.city ='苏州市' then 10
                when a.city ='西安市' then 11
                when a.city ='长沙市' then 12
                when a.city ='沈阳市' then 13
                when a.city ='青岛市' then 14
                when a.city ='郑州市' then 15
                when a.city ='大连市' then 16
                when a.city ='东莞市' then 17  
                else 18
                end,
            CONVERT( a.province USING gbk ) COLLATE gbk_chinese_ci asc,
            CONVERT( a.city USING gbk ) COLLATE gbk_chinese_ci asc

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JB091

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值