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
)