UPDATE mini_stray_animal_note
SET comment_count = comment_count + 1
WHERE id = #{noteId}
UPDATE mini_stray_animal_note n
SET n.comment_count = (
SELECT COUNT(1)
FROM mini_stray_animal_note_comment c
WHERE c.note_id = n.id
AND c.flag = 0
)
WHERE 1 = 1
UPDATE mini_stray_animal_note n
INNER JOIN (
SELECT note_id, MAX(create_time) as last_comment_time
FROM mini_stray_animal_note_comment
WHERE create_time >= DATE_SUB(NOW(), INTERVAL 1 DAY)
GROUP BY note_id
) c ON n.id = c.note_id
SET n.comment_count = (
SELECT COUNT(1)
FROM mini_stray_animal_note_comment c2
WHERE c2.note_id = n.id AND c2.flag = 0
)