我用這個查詢更新由作者發表如何通過COUNT從另一個表在我的SQL更新
UPDATE authors SET total_articles =
(
SELECT COUNT(*) FROM articles
WHERE articles.author_id=authors.author_id
GROUP BY author_id
)
然而,文章,當我添加一個額外的WHERE
條款來算只發表的文章作爲
UPDATE authors SET published_articles =
(
SELECT COUNT(*) FROM articles
WHERE articles.author_id=authors.author_id AND articles.status='published'
GROUP BY author_id
)
count(*)
未正確計算已發佈文章的數量。