commento/db/20180923004309-comment-count-build.sql

11 lines
224 B
MySQL
Raw Normal View History

2018-09-23 12:47:38 +08:00
-- Build the comments count column
UPDATE pages
SET commentCount = subquery.commentCount
FROM (
SELECT COUNT(commentHex) as commentCount
FROM comments
WHERE state = 'approved'
GROUP BY (domain, path)
) as subquery;