通过此相关性查询,我试图通过查询tags
中的部分“计算”来选择/查找标签tag
。articles
“计算思想”。id
16,但是似乎找不到多个标签。一旦我搜索“ almere”,它就会给出所需的文章结果(article
。id
16和15)
SELECT s.seoUrl, a.*,
(
(
if (t.tag LIKE '%computational%',7,0)
)+
(
if (a.title LIKE '%computational%',5,0)
)+
(
if (a.shortDescription LIKE '%computational%',4,0)
)+
(
if (a.content LIKE '%computational%',3,0)
)+
(
if (m.name LIKE '%computational%',2,0)
)+
(
if (s.seoUrl LIKE '%computational%',1,0)
)
) as relevance
FROM articles a
LEFT JOIN article_tag at ON at.articleId = a.contentId
LEFT JOIN seoUrls s ON s.contentId = a.contentId
LEFT JOIN tags t ON at.tagId = t.contentId
LEFT JOIN article_category ac ON ac.articleId = a.contentId
LEFT JOIN menu m ON m.contentId = ac.categoryParentId
WHERE a.published = 'on'
GROUP BY a.contentId
HAVING relevance > 0
ORDER BY relevance DESC, a.views DESC
我认为我在选择标签时在左连接处犯了一个大错误,但我似乎找不到解决办法,有什么主意吗?