**1. 自定义排序函数FIELD()**SELECT id,username,city FROM sy_user order byFIELD(city,'郑州', '开封', '平顶山','洛阳', '商丘', '安阳', '新乡', '许昌', '鹤壁', '焦作', '濮阳', '漯河', '三门峡', '周口','驻马店', '南阳', '信阳', '济源','省本部','河南')
**2.使用 case when**SELECT id,username,city FROM `sy_user` ORDER BY case
when city like '%省%' then 1
when city like '%郑州%' then 2
when city like '%开封%' then 3
when city like '%平顶山%' then 4
when city like '%洛阳%' then 5
when city like '%商丘%' then 6
when city like '%安阳%' then 7
when city like '%新乡%' then 8
when city like '%鹤壁%' then 9
when city like '%焦作%' then 10
when city like '%濮阳%' then 11
when city like '%漯河%' then 12
when city like '%三门峡%' then 13
when city like '%周口%' then 14
when city like '%驻马店%' then 15
when city like '%南阳%' then 16
when city like '%信阳%' then 17
when city like '%济源%' then 18
end
asc
网上有一些关于like %xxx%的优化建议,比如 locate, instr, position的方式,但是亲测之后发现这几个方式也是全表扫描。如果数据量庞大的话,还是建议直接使用搜索引擎elasticsearch。