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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:56:39+00:00 2026-05-11T11:56:39+00:00

The actual question is a little more complex than that, so here goes. I

  • 0

The actual question is a little more complex than that, so here goes.

I have a website which reviews games. Ratings/reviews are posted for each game, and so I have a MySQL database to handle it all.

Thing is, I’d really like a page that showed what score (out of 10) meant what, and to illustrate it would have the game that was last reviewed as an example. I can always do it without, but this would be cooler.

So the query should return something like this (but running from 10 to 0):

|---------------*----------------*-----------------*-----------------| * game.gameName | game.gameImage | review.ourScore | review.postedOn * |---------------*----------------*-----------------*-----------------| | Top Game      | img            | 10              | (unix timestamp)| | NearlyTop Game| img            | 9               | (unix timestamp)| | Great Game    | img            | 8               | (unix timestamp)| |---------------*----------------*-----------------*-----------------| 

The information is in two tables, game and review. I think you’d use MAX() to find out the last timestamp and corresponding game information, but as far as complex queries go, I’m in way over my head.

Of course this could be done with 10 simple SELECTs but I’m sure there must be a way to do this in one query.

Thanks for any help.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T11:56:39+00:00Added an answer on May 11, 2026 at 11:56 am

    Here is an ugly solution I found:

    This query simply gets the IDs and scores of the reviews that you want to look at. I have included it so that you can understand what the trick is, without getting distracted by other stuff:

    SELECT * FROM (SELECT reviewID, ourScore FROM review ORDER BY postedOn DESC) as `r` GROUP BY ourScore ORDER BY ourScore DESC; 

    This exploits MySQL’s ‘GROUP BY’ behavior. When the grouping is done, if the source rows have different values for different columns, then the value of the topmost source row is used. So if you had rows in this order:

    reviewId  Score 1           3 0           3 2           3 

    Then after you group by score, the reviewId is 1 because that row was on the top:

    reviewId  Score 1           3 

    So we want to put the most recent review on the top before we do the group by. Since ORDERing is always dones after grouping, in a single SELECT statement, I had to make a subquery to accomplish this. Now we just dress up this query a little bit to get all the fields you wanted:

    SELECT `r`.*, game.gameName, game.gameImage FROM (SELECT reviewID, ourScore, postedOn, gameID FROM review ORDER BY **postedOn DESC**) as `r` JOIN game ON `r`.gameID = game.gameID GROUP BY ourScore ORDER BY ourScore DESC; 

    That should work.

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

Sidebar

Related Questions

This is more of a theoretical question than an actual problem I have. If
This is something now more of curiosity than actual purpose. If you have a
this is more of a 'best practice' question than an actual problem: I'm working
This goes back to my other question which I thought was sufficiently answers but
So, here is my little problem. Let's say I have a list of buckets
A bit more specific than Stack Overflow question What is an existential type? ,
NOTE: This question changed a little as I learned more about the problem, so
I have done a little research here on SO and haven't found exactly what
Or maybe the question is more like What am I doing blatantly wrong here?
The question I have is a bit of a ethical one. I read here

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.