搜索是很多網(wǎng)站需要具備的,因為這方面了瀏覽者,也方便網(wǎng)站帶來流量。那么,有的搜索是基于關鍵詞的,比如搜索一個“北京網(wǎng)站建設”。就查找和“北京網(wǎng)站建設”有關的標題或者代碼,但是你可能希望搜索的更多,為什么呢? 網(wǎng)站搜索結果按相關性進行排序的SQL語句實現(xiàn)思路,如果先按標題中同時出現(xiàn)"數(shù)據(jù)庫"和"Sql" >> 內容中同時出現(xiàn)"數(shù)據(jù)庫"和"Sql" >> 標題中出現(xiàn)"數(shù)據(jù)庫"或"Sql" >>內容中出現(xiàn)"數(shù)據(jù)庫"或"Sql" 再按時間降序只能用添加輔助列的方法實現(xiàn): Select Title,Content,case when Title like ’%北京網(wǎng)站建設%’ and Title like ’%Sql%’ then 1 when Content like ’%北京網(wǎng)站建設%’ and Content like ’%Sql%’ then 2 when Title like ’%北京網(wǎng)站建設%’ or Title like ’%Sql%’ then 3 when Content like ’%北京網(wǎng)站建設%’ or Content like ’%Sql%’ then 4 end as priority from Article order by priority,tTime desc 利用上面的SQL語句,網(wǎng)站搜索結果按相關性進行排序可以進行初步實現(xiàn)了哦。
北京歡迎你科技有限公司原創(chuàng)文章,關鍵詞:北京網(wǎng)站建設北京建網(wǎng)站北京網(wǎng)站制作 轉載請注明出處:m.hzgwjy.com謝謝!
上一篇 :北京網(wǎng)站建設公司告訴你什么是網(wǎng)站運營?應該怎么做? 下一篇 :北京網(wǎng)站制作公司與大家分享網(wǎng)站要怎么保持活力呢?