我需要根據使用mysql的單詞的重複性來排序結果。在mysql中按特定字數排序
這裏是我的樣品臺
id Name keywords Description
1 John John, USA John is good boy. John, John
2 Alex Alex, John Alex is a friend of john.
3 Rocky John Rocky
4 John John,John John, John, John, John, John
將採取 「約翰」 爲例。在第一行中,「約翰」重複5次,第二行重複2次,第三行重複1次,第四行重複8次。我需要根據計數遞減來顯示結果。
Select * From table Where name like '%John%' OR keywords like '%John%' OR Description like '%John%'
所以會顯示下訂單
id Name keywords Description
4 John John,John John, John, John, John, John
1 John John, USA John is good boy. John, John
2 Alex Alex, John Alex is a friend of john.
3 Rocky John Rocky
https://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html#f unction_match – M0rtiis
這裏有一個類似的問題:[count-the-number-of-a-string-in-a-varchar-field](http://stackoverflow.com/questions/12344795/count-the -n-varchar-field) – cars10m