我构建以下查询,
SELECT
posts.id,
posts.useraid,
posts.useradn,
posts.title,
posts.createdate,
posts.forumid,
posts.type,
posts.totalreplys,
users.photo AS creatorphoto
FROM posts
JOIN users ON(users.id = posts.useraid)
WHERE posts.forumid IN(
SELECT subscribe.forumid AS fsub
FROM subscribe
WHERE subscribe.useraid = '$myid'
) AND
posts.forumid IN(
SELECT forums.id
FROM forums
WHERE forums.relatedto=fsub
)
AND posts.type='post'
ORDER BY posts.timee DESC LIMIT 20
没有这部分代码可以完美运行
AND
posts.forumid IN(
SELECT forums.id
FROM forums
WHERE forums.relatedto=fsub
)
但是,我需要查询来选择他订阅的所有论坛中的所有帖子,包括子论坛帖子。