这句mysql语句怎么排先后呀?
SELECT * FROM text where (`title` like '%我们%' and `title` like '%他们%') or (`title` like '%我们%' or `title` like '%他们%') limit 6
有办法先把前一个条件的(`title` like '%我们%' and `title` like '%他们%')列出来在列出后面条件的吗?
------解决方案--------------------
试试这样?
SELECT *, ((`title` like '%我们%' and `title` like '%他们%') * 0.8 + (`title` like '%我们%' or `title` like '%他们%') * 0.2) AS relevanceFROM textWHERE (`title` like '%我们%' and `title` like '%他们%') or (`title` like '%我们%' or `title` like '%他们%') ORDER BY relevance DESClimit 6<br><font color="#e78608">------解决方案--------------------</font><br>
SELECT * FROM ( SELECT * FROM `text` where `title` like '%我们%' and `title` like '%他们%') ttWHERE `title` like '%我们%' or `title` like '%他们%' limit 6;<br><font color="#e78608">------解决方案--------------------</font><br>
SELECT *, 1 as xh FROM text where (`title` like '%我们%' and `title` like '%他们%')unionSELECT *, 2 as xh FROM text where (`title` like '%我们%' or `title` like '%他们%')order by xhlimit 6<div class="clear"> </div>