日期:2014-05-17 浏览次数:20506 次
SELECT *, ((`title` like '%我们%' and `title` like '%他们%') * 0.8 + (`title` like '%我们%' or `title` like '%他们%') * 0.2) AS relevance FROM text WHERE (`title` like '%我们%' and `title` like '%他们%') or (`title` like '%我们%' or `title` like '%他们%') ORDER BY relevance DESC limit 6
------解决方案--------------------
SELECT * FROM ( SELECT * FROM `text` where `title` like '%我们%' and `title` like '%他们%' ) tt WHERE `title` like '%我们%' or `title` like '%他们%' limit 6;
------解决方案--------------------
SELECT *, 1 as xh FROM text where (`title` like '%我们%' and `title` like '%他们%') union SELECT *, 2 as xh FROM text where (`title` like '%我们%' or `title` like '%他们%') order by xh limit 6