日期:2014-05-17 浏览次数:20594 次
--对结果再进行一次title LIKE '%keyword%'就可以了 ;with cte as ( SELECT * FROM T_Article WHERE title LIKE '%keyword%' OR content LIKE '%keyword%' ) select * from cte WHERE title LIKE '%keyword%' --或 select * from ( SELECT * FROM T_Article WHERE title LIKE '%keyword%' OR content LIKE '%keyword%' ) t WHERE t.title LIKE '%keyword%'
------解决方案--------------------
select * from ( SELECT *,xh=1 FROM T_Article WHERE title LIKE '%keyword%' union all select *,xh=2 FROM T_Article WHERE content LIKE '%keyword%' )a order by xh
------解决方案--------------------
SELECT * FROM T_Article WHERE title LIKE '%keyword%' OR content LIKE '%keyword%' order by case when title LIKE '%keyword%' then 0 else 1 end