PHP+MYSQL 多關鍵詞+模糊搜尋+匹配度排序,請問如何?

來源:互聯網
上載者:User
PHP+MYSQL 多關鍵詞+模糊搜尋+匹配度排序,請教怎麼實現?
已經用MYSQL 的 UNION 實現了一個,但是效率太差,請教論壇上的高人有沒有更好的方法。 mysql php 模糊搜尋 排序


------解決方案--------------------
既然你不需要計算出現的次數,那麼合起來不是更好
SELECT a.`askid`,a.`catid`,a.`title`,a.`status`,a.`addtime`,a.`reward`,a.`answercount`,b.`message` 
FROM `phpcms_ask` a LEFT JOIN `phpcms_ask_posts` b ON a.`askid`=b.`askid`
WHERE (a.status=3 OR a.status=5) AND b.`isask`=1 AND (LOCATE('中國',a.`title`)>0 OR LOCATE('北京',a.`title`)>0 OR LOCATE('天安門',a.`title`)>0)

------解決方案--------------------
若要計算匹配度,也只需
select sign(LOCATE('中國',a.`title`))+sign(LOCATE('北京',a.`title`))+sign(LOCATE('天安門',a.`title`)) as 匹配數 from ...
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.