I build the following query,
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
The code works perfectly without this part
AND
posts.forumid IN(
SELECT forums.id
FROM forums
WHERE forums.relatedto=fsub
)
But, I need the query to select all posts from all forums he subscribe to, including the subforums posts.