Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 280765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:08:47+00:00 2026-05-12T05:08:47+00:00

Okay I have three tables that all communicate with each other. ForumTopic t ForumMessage

  • 0

Okay I have three tables that all communicate with each other.

ForumTopic t
ForumMessage m
ForumUser u

What I am trying to do is get the first message of each Topic.

I have tried this

  SELECT
   m.[Message], m.[TopicID], m.[Posted], u.Name, t.[Views], t.NumPosts,
   t.Topic
   FROM [ForumMessage] m
   INNER JOIN ( SELECT TopicID, Topic, [Views], NumPosts, ForumID
    FROM [ForumTopic]
    GROUP BY TopicID, Topic, [Views], NumPosts, ForumID ) t ON t.TopicID = m.TopicID
   INNER JOIN [ForumUser] u
   ON u.UserID = m.UserID
   WHERE t.ForumID IN(1,2)
   ORDER BY m.Posted DESC;

And the Result is listed below

 Message    TopicID Posted  Name    Views   NumPosts    Topic
    6   2009-07-20 18:14:06.270 Ravenal 26  3   GENESIS 2.5.1a RELEASE
    6   2009-07-20 18:08:51.027 Ryan    26  3   GENESIS 2.5.1a RELEASE
    6   2009-07-20 17:06:33.550 Ravenal 26  3   GENESIS 2.5.1a RELEASE
    4   2009-07-17 14:22:47.560 Ravenal 14  1   MyGameTools IRC
    3   2009-07-17 01:09:22.403 Ravenal 43  1   GENESIS 2.5.0b RELEASE
    2   2009-07-17 00:48:30.873 Ravenal 44  2   GENESIS 2.5.0a RELEASE
    2   2009-07-16 23:08:44.830 Ravenal 44  2   GENESIS 2.5.0a RELEASE
    1   2009-07-16 23:03:11.790 Ravenal 20  1   Welcome to MyGameTools

So I am trying to figure out how to make it so that it ends up looking like this

 Message    TopicID Posted  Name    Views   NumPosts    Topic
    6   2009-07-20 18:14:06.270 Ravenal 26  3   GENESIS 2.5.1a RELEASE
    4   2009-07-17 14:22:47.560 Ravenal 14  1   MyGameTools IRC
    3   2009-07-17 01:09:22.403 Ravenal 43  1   GENESIS 2.5.0b RELEASE
    1   2009-07-16 23:03:11.790 Ravenal 20  1   Welcome to MyGameTools

Any help will be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:08:47+00:00Added an answer on May 12, 2026 at 5:08 am

    Have you tried using a derived table to get the max posted datetime for each topic from the ForumMessages table?

    eg

    SELECT   m.[Message], m.[TopicID], m.[Posted], u.Name, t.[Views], t.NumPosts,   t.Topic   FROM 
    ( SELECT TopicID, Max(Posted) MaxPosted
      FROM ForumMessage
      GROUP BY TopicID ) MaxMessage
    INNER JOIN [ForumMessage] m   
      ON m.TopicID = maxMessage.TopicID
      AND m.Posted = maxMessage.MaxPosted
    INNER JOIN ( SELECT TopicID, Topic, [Views], NumPosts, ForumID
        FROM [ForumTopic]
        GROUP BY TopicID, Topic, [Views], NumPosts, ForumID ) t 
      ON t.TopicID = m.TopicID
    INNER JOIN [ForumUser] u
       ON u.UserID = m.UserID   
    WHERE t.ForumID IN(1,2)   
    ORDER BY m.Posted DESC;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have three tables I am trying to pull data from with the
Okay, I have 3 tables: Students Offered_subjects Enrollees_list Students will contain all the information
Okay I have a large CRUD app that uses tabs with Forms embedded in
Okay so I have this mode: class Posts(db.Model): rand1 = db.FloatProperty() #other models here
Okay so I have a web view that holds the chat bar div from
In Access 2007, I have two tables related such that the (surrogate) PK of
Okay, so I have a client who wants to output all information for a
hiya i have a massive job trying to sort thousands of records all is
QUESTION: Is it okay to have shortcut identifiers in a table so that I
I have an app that loads several resources when it's first run, which are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.