注册 X
我已阅读并同意  服务条款
首页 > IT技术笔记 > 查看笔记

mysql分词查询并根据关键词匹配度进行排序

sql查询后需要根据匹配度降序排列显示

点击复制

select (if(LOCATE('tomcat',notetitle),1,0)+ if(LOCATE('nginx',notetitle),1,0)+if(LOCATE('linux',notetitle),1,0)) 
as score,notetitle from technicalnote 
where notetitle like'%tomcat%' or notetitle like '%nginx%' or notetitle like '%linux%' order by score desc			
		

 打赏        分享



评论