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 8882273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:32:13+00:00 2026-06-14T20:32:13+00:00

Im working on status table I’ll show basic information per user and what filtering

  • 0

Im working on status table I’ll show basic information per user and what filtering needs to happen having an issue getting the latest status per user and grouping by user.

So the status table information that I need to use is:

  • ID
  • content
  • userID

and the user information I need to use is:

  • ID
  • locationID

So the end result of what I want to achieve is having is the latest status of each user grouped by user.

I was using:

SELECT ID, content
    FROM status
    WHERE content NOT RLIKE "#[0-9azA-Z]"
    AND type = "5"
    AND userID IN (
        SELECT DISTINCT ID
        FROM users
        WHERE hometownID = "'.$locationID.'"
        OR locationID = "'.$locationID.'"
    )
    GROUP BY status.userID
    ORDER BY addedDate DESC

And then I was grouping by user in PHP using an array of already added users and excluding them, but this is not ideal for scaling up and loading more results after, so I want a SQL only solution.

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-14T20:32:14+00:00Added an answer on June 14, 2026 at 8:32 pm

    This is working for me!

    SELECT *
    FROM status
    NATURAL JOIN (
        SELECT userID, MAX(addedDate) as addedDate
        FROM status
        GROUP BY userID
    ) AS mostRecent
    WHERE userID IN (
        SELECT DISTINCT ID
        FROM users
        WHERE users.locationID = "'.$locationID.'"
        OR users.hometownID = "'.$locationID.'"
    )
    AND status.content NOT RLIKE "#[0-9azA-Z]"
    AND type = "5"
    #AND userID != "'.$userID.'"
    ORDER BY status.addedDate DESC
    LIMIT 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an application that stores user inputs into the database table via
I'm working on an application to display the battery status of then phone/tablet. I
Hey guys, I'm working on a status-Updater. It works, there is just one problem,
I am working on an app in which I want to toggle the status
I am working on a hangman program and I want to output a status
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
the jsonp response looks like google.visualization.Query.setResponse({version:'0.6',status:'ok',sig:'2041370208',table:{cols:[{id:'coupon',label:'Coupon',type:'string',pattern:''},{id:'con',label:'Conversion',type:'number',pattern:''},{id:'convert',label:'Converted Carts',type:'number',pattern:''},{id:'displayed',label:'Displayed',type:'number',pattern:''},{id:'converted',label:'Converted',type:'number',pattern:''},{id:'status',label:'Status',type:'boolean',pattern:''}],rows:[{c:[{v:'test'},{v:0.33},{v:1.01},{v:3.0},{v:1.0},{v:false}]}]}}) just trying to get it working with
I need to update existing users IsApproved status in the aspnet_Membership table. I have
i have a gridview with search option by a database table.All working fine but
I am working on Oracle 10gR2 I have a MERGE statement for a table,

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.