扫码关注官方订阅号
三个表:artice,tag,map。map表记录了一篇article的tag,现在读出一篇article,然后根据tag查找相关性最高的其他artice,用什么方法最好?用mysql in(tagid1,tagid2,tagid3)这样的形式,能不能根据in里面出现的次数来排序?
走同样的路,发现不同的人生
select * from map as m left join ( select tagid, count(tagid) as c from map where tagid in (tag1, tag2, tag3) group by tagid -- order by count(tagid) desc ) as ct on m.tagid=ct.tagid left join article as a on m.articleid=a.id order by ct.c desc
这种最好用全文搜索来做。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
这种最好用全文搜索来做。