日期:2014-05-16  浏览次数:20497 次

一条sql语句且无论id=100在不在模糊查询里都要排在查询结果的第一行
select * from A where 1=1 and name like '%张三%'

select * from A where id=100

我想要的是两条语句的总结果,即合并为一条sql语句且无论id=100在不在模糊查询里都要排在查询结果的第一行

在线急等答案
------解决方案--------------------
试试这个:

select * from A 
where 1=1 and (name like '%张三%' or id=100)
order by case when id = 100 then 0 else id end