How to sort this mysql statement? SELECT * FROMtextwhere ('title' like % we % and 'title' like % They %) or ('title' like % we % or 'title' like % They %) limit6 has a way to sort the mysql statement ('title' like % we % and) in the previous condition first?
SELECT * FROM text where ('title' like '% we %' and 'title' like '% They % ') or ('title' like '% we %' or 'title' like '% They %') limit 6
Is there a way to first list the ('title' like '% we %' and 'title' like '% They %') of the previous condition to list the following conditions?
------ Solution --------------------
Try this?
SQL code
SELECT *, ('title' like '% we %' and 'title' like '% They % ') * 0.8 + ('title' like' % 'or 'title' like' % %') * 0.2) AS relevanceFROM textWHERE ('title' like '% we %' and 'title' like '% They % ') or ('title' like '% we %' or 'title' like '% They %') order by relevance DESClimit 6
------ Solution --------------------
SQL code
SELECT * FROM (SELECT * FROM 'text' where 'title' like '% we %' and 'title' like '% They % ') ttWHERE 'title' like '% we %' or 'title' like '% They % 'limit 6;
------ Solution --------------------
SQL code
SELECT *, 1 as xh FROM text where ('title' like '% we %' and 'title' like '% They %') unionSELECT *, 2 as xh FROM text where ('title' like '% we %' or 'title' like '% They %') order by xhlimit 6