帖子通知实际上存储在 post_custom_fields 表中,因此您可以像这样获取更精确的帖子列表:
-- [params]
-- int :days_ago = 7
SELECT p.created_at,
p.id AS post_id,
p.user_id,
pcf.value AS "notice type"
FROM post_custom_fields pcf
INNER JOIN posts p ON pcf.post_id = p.id
INNER JOIN topics t ON p.topic_id = t.id
WHERE pcf.name = 'notice_type'
AND p.created_at > NOW() - INTERVAL ':days_ago days'
AND t.archetype = 'regular'
ORDER BY p.created_at ASC