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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:34:41+00:00 2026-05-12T19:34:41+00:00

SELECT user_id, created FROM photo_comments GROUP BY user_id returns user_id created 1 2009-10-20 21:08:22

  • 0
SELECT user_id, created FROM photo_comments GROUP BY user_id

returns

  user_id  created  
  1        2009-10-20 21:08:22 
  12       2009-10-20 21:45:00 
  16       2009-10-28 20:35:30 

But that created date of 2009-10-20 for user id 1 is the first entry by user id 1.

How can I get the last entry by user id 1? (date should be 2009-11-02)

I’m trying to get the last entry by each user in order of most recent first.

  • 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-12T19:34:42+00:00Added an answer on May 12, 2026 at 7:34 pm

    Ordinary SQL isn’t supposed to allow that sort of query in the first place. In theory, you can only request a field that you named in a GROUP BY clause or an aggregate function of some other field. Here’s how you’d build your modified query. (Then you can add other fields too on the first line.)

    SELECT user_id, created
    FROM photo_comments o
    WHERE created =
        (SELECT MAX(created) 
        FROM photo_comments i
        WHERE o.user_id=i.user_id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query like this SELECT user_id FROM user WHERE user_id NOT IN
cursor.execute(SELECT user_id FROM myapp_location WHERE\ GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) < %s\ ,(user_utm_easting, user_utm_northing, 500)); This
Say I have the following: $query = SELECT user_id,email,password, roles.role_id,role_name FROM users JOIN roles
This problem is baffling me: BEGIN; INSERT INTO sub_users(user_id, email) SELECT user_id FROM users
I have an application that executes the following MySQL query: SELECT 402 AS user_id,
Every user in my database has a first name. How can I find a
I created a procedure that is supposed to do some operation but every time
I have a SELECT statement that looks like this: SELECT * FROM photos, p_votes
I have a html file which select images from user's computer.code is given bellow
I tried this select posts.id, posts.title from posts inner join ( select post_id,max(created) from

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.