Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex Query

Status
Not open for further replies.

asfaw

Programmer
Jun 28, 2004
36
CA
Hello all,

I have the following MyISAM tables:

Forum
(forumid, name, description)
Post
(postid, forumid, userid, topicid, subject, message, date)
Topic
(topicid, userid, forumid, subject)
User
(userid, login, password)

I am trying to get a list of all the forums groupd by forum name, total count of post for each forum, total topics for each forum, the login (i.e. the last person who posted in each forum), and the last post date.


I have done a good part of it. I need your help on how to pull the last person who posted in each forum and the last post date.

SELECT
Forum.forumId as forumId, Forum.name as name ,description,
count(DISTINCT Topic.topicid) as countTopics,
count(DISTINCT Post.postid) as countPosts,
DATE_FORMAT(Max(Post.date), '%M %d, %Y %h:%i %p') as date,
login

FROM Forum, Topic, Post, User

WHERE Forum.forumId = Topic.forumId
AND Forum.forumId = Post.forumId
GROUP BY name;

Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top