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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:52:09+00:00 2026-06-11T10:52:09+00:00

I have 2 tables that look like this: users (uid, name) ——————- | 1

  • 0

I have 2 tables that look like this:

users (uid, name)
-------------------
|  1  |  User 1   |
|  2  |  User 2   |
|  3  |  User 3   |
|  4  |  User 4   |
|  5  |  User 5   |
-------------------

highscores (user_id, time)
-------------------
|  3 |   12005    |
|  3 |   29505    |
|  3 |   17505    |
|  5 |   19505    |
-------------------

I want to query only for users that have a highscore and only the top highscore of each user. The result should look like:

------------------------
|  User 3 |   29505    |
|  User 5 |   19505    |
------------------------

My query looks like this:

SELECT user.name, highscores.time
FROM user
INNER JOIN highscores ON user.uid = highscores.user_id
ORDER BY time ASC 
LIMIT 0 , 10

Actually this returns multiple highscores of the same user. I also tried to group them but it did not work since it did not return the best result but a random one (eg: for user id 3 it returned 17505 instead of 29505).

Many thanks!

  • 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-11T10:52:11+00:00Added an answer on June 11, 2026 at 10:52 am

    You should use the aggregated function MAX() together with group by clause.

    SELECT  a.name, MAX(b.`time`) maxTime
    FROM    users a
            INNER JOIN highscores b
                on a.uid = b.user_id
    GROUP BY a.name
    

    SQLFiddle Demo

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

Sidebar

Related Questions

I have 3 tables that look something like this: Table1 Users: ID Name Score
I have a database that consists of two tables, which look like this: users
Say I have three tables that look like: users: id event_registration: id user_id event_id
Let's say I have two tables that look like this: TH TH TH TH
I have a 3 tables that look like this: (source: InsomniacGeek.com ) On the
I have three tables...users, user_info, and quota_levels. They look like this: CREATE TABLE users
so I have this problem. My Database has two tables that look something like
I have MySQL database with two tables: users and items. They look like this:
I have 3 tables Labels UserValues Users Labels looks like this: 1|First Name 2|Last
I have a table posts that could look like this: id | title |

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.