我需要按一个列与另一列完全相同的值排序。有没有办法做到这一点?如果有,请告诉我。 ORDER BY wordMatch = wordCount
SELECT * ,
( input LIKE '% i %') +
( input LIKE '% love %' ) +
( input LIKE '% you %' ) AS wordMatch,
( LENGTH( input ) - LENGTH( REPLACE( input, ' ', '' ) ) -1 ) AS wordCount
FROM allData
HAVING wordMatch > ( wordCount * 0.6666 )
AND wordCount > ( 3 * 0.6666 )
ORDER BY wordMatch = wordCount
LIMIT 50
答案 0 :(得分:1)
如果您想要最接近的匹配,请使用desc
:
order by (wordMatch = wordCount) desc
或者,您可能还需要差异的绝对值:
order by abs(wordMatch - wordCount)
答案 1 :(得分:0)
我正在寻找这样的事情:
ORDER BY wordMatch = wordCount DESC , wordCount DESC