Reputation:
I have the following table diagramm.
One forum can have one or more subforums.
Example:
id descr parentforumid
1 first 0
2 second 0
3 third 1
4 fourth 1
5 fifth 3
6 sixth 2
My aim is when I will get the last posts and set as forumid = 1, that I get all posts from forumid 1 and forumid 3 and forumid 4 and forumid 5.
And when I search for the forumid = 3, then I should get all posts from forumid 3 and forumid 5
I know that I need a recursivly function where I got all the forumid's for searching in the posts, but I have no idea how I starts the solution.
Maybe you have some tipps in which way I have to look or to search.
Upvotes: 1
Views: 39
Reputation: 295
Why won't a simple OR do it? For ex SELECT whatever from table where (id=3 or parentid=3) order by sometimestamp desc limit 5
Upvotes: 0