我试图从一系列表格中提取多个部分。我将提出一个不太复杂的问题,实际上代表了一个更大的功能/查询
我有wins_category,review,review_like表格。
winning_category = category_id, category_name, id
review = id, header
review_like = id, review_id
我将首先提出一个查询,用于从这5个表中收集计数,共享计数,查看次数,审核。*
SELECT COUNT(DISTINCT a_like.article_like_id) AS likecount, a.* FROM article AS a
LEFT JOIN article_like AS a_like ON a.id = a_like.article_id
WHERE a.created_date BETWEEN '2017-07-01 00:00:00' AND '2017-08-01 00:00:00'
GROUP BY a.id
ORDER BY likecount
DESC OFFSET 0 LIMIT 10
现在我们有了我的问题
SELECT
COUNT(DISTINCT r_like.review_like_id) AS likecount,
r.header AS r_header,
w.category_name
FROM review AS r
LEFT JOIN review_like AS r_like ON r.id = r_like.review_id
LEFT JOIN winning_category AS w ON r.id = w.category_id
WHERE r.id = w.category_id
GROUP BY r.id
ORDER BY likecount;
它说"" w.category_name"必须出现在GROUP BY子句中或用于聚合函数" ....
我已经阅读了这篇文章here以及许多类似的帖子,这些帖子没有我需要的内容
任何提示都会很受欢迎