user
forum
subforum
discussions are tied to one specific projects so we don’t need categories
user {userid, username, password, displayname, active, email, deleted}
forum{forumid, projectid, userid, title, body, createdate, deleted, admincomment}
subforum {subforumid, forumid, userid, projectid, body, createdate, deleted}
forum(topic) was getting displayed with latest forum at the top. when user clicked on forum title it opens new page with forum title on top and subforums(replies) under it.
on main page we displaying forum as table
topic|created by and datetime of creation| replies | last reply
i wanted to dsiplay topic sorted according to the last reply posted but faced aproblem
problem is that when i join 3 tables main forum with no replies did not get displayed but it get sorted by last reply posted
sql
SELECT f.forumid, f.userid, f.title, f.body, u.displayname, f.createdate, s.createdate as replydate FROM forum f INNER JOIN users u ON f.userid = u.userid join (select * from subforum where deleted=0 order by createdate desc) as s on s.forumid=f.forumid WHERE f.projectid = 220 AND f.deleted=0 and s.deleted =0 group by f.forumid ORDER BY replydate desc;
problem is with database design. i have always seen posts as one table and reply to posts in same table.
database was designed like this before i joined the project.
is there a way to achieve the result i wanted with this design?
thanks