Mysql分词查询排序

SELECT words FROM `tbresearch_list` where keywords = 30 AND  words REGEXP 'energy|sulfur|fluoride' ORDER BY (
    CHAR_LENGTH(words) - CHAR_LENGTH(REPLACE(words, 'a b c', ''))
  ) / 5 DESC,
  (
    CHAR_LENGTH(words) - CHAR_LENGTH(REPLACE(words, 'a', ''))
  ) / 1 + (
    CHAR_LENGTH(words) - CHAR_LENGTH(REPLACE(words, 'b', ''))
  ) / 1 + (
    CHAR_LENGTH(words) - CHAR_LENGTH(REPLACE(words, 'c', ''))
) / 1 DESC

  

posted @ 2024-05-31 17:32  TOPHP  阅读(15)  评论(0编辑  收藏  举报