select * from company where city like '%北京%' and top like '北京' order by id desc union select * from company where city like '%北京%' and top not like '北京' order by id desc
select * from company where city like '%北京%' and top like '北京' order by id desc union select * from company where city like '%北京%' and top not like '北京' order by id desc
试试这个,测试可以 SELECT * FROM test WHERE city LIKE '%北京%' ORDER BY ( top LIKE '%北京%' ) DESC , id DESC
select * from company where city like '%北京%' and top like '北京' order by id desc union select * from company where city like '%北京%' and top not like '北京' order by id desc
select * from company where city like '%北京%' and top like '北京' order by id desc union select * from company where city like '%北京%' and top not like '北京' order by id desc
SELECT *
FROM test
WHERE city LIKE '%北京%'
ORDER BY (
top LIKE '%北京%'
) DESC , id DESC