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

  • SEARCH
  • Home
  • 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 7954509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:27:00+00:00 2026-06-04T03:27:00+00:00

I have a social network I am coding but it’s a bit different than

  • 0

I have a social network I am coding but it’s a bit different than others, in this case there is only ever one status show per user on a feed section.

So I need to sort the status by date with the latest ones on top but also group by the userID
unfortunately I can’t seem to get this working….

This is my current query:

SELECT *
FROM status
WHERE userID != "83" #This is just so my statuses don't show
GROUP BY userID
ORDER BY addedDate DESC
LIMIT 10

I expect to see the latest status results and only one per user instead I see the first statuses so the group by is working but not the order by.

Thanks in advance.

  • 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-06-04T03:27:02+00:00Added an answer on June 4, 2026 at 3:27 am

    As mentioned in the comments to Robin’s answer, that approach is unreliable because MySQL does not guarantee that it will always return the most recent status from each group. You must instead join your table with a subquery that selects the most recent status (based on addedDate).

    SELECT   *
    FROM     status
      NATURAL JOIN (
        SELECT   userID, MAX(addedDate) as addedDate
        FROM     status
        GROUP BY userID
      ) AS mostRecent
    ORDER BY addedDate DESC
    LIMIT    10
    

    Note that if a user has multiple status updates with the same addedDate, the server will return all of them (whereas Robin’s query would return an indeterminate one); if you need control over such a situation, you will need to define how one determines which such status update should be selected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have chosen diploma work in university. It's a mini social network. But now
I have a social network for the cystic fibrosis community. There is a section
I have a social network similar to myspace but I use PHP and mysql,
I have a social network so a blog is only you could say a
There's this project I am working on. This is like a social network where
I have this problem for my social network website. I want to make an
I have to develop a basic social network for an academic purpose; but I
I have been browsing some social network, and found there an ability to search
I'm creating a social network in Rails and I have a model like this:
I am working on a social network project in PHP/MySQL. If you have ever

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.