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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:31:17+00:00 2026-06-08T19:31:17+00:00

I have a high scores table scores: (id int, deviceid int, value int, board

  • 0

I have a high scores table scores: (id int, deviceid int, value int, board int).
I’d like to display a position for a specific player. At the moment I’m doing this (in PHP):

I select all boards where the player has a score and the score itself:

select board, min(value) as value
from scores
where deviceid = 1234
group by board

Then for each row ($board,$value) I select:

select count(id) from scores
where board = $board and value < $value

by selecting number of rows for specific board with score less than specified value, I get the player’s position (first player would get position 0, so it will be increased by 1 when displayed)

I know this is horribly unefficient, so I’m looking for a way to do it faster. It could possibly be done in a stored procedure with a cursor, but for 100 boards, I will need to do at most 1+100 selects.

I a nutshell, I would like to do something like this, in pseudo-sql:

select board, min(value) as val,
       count(id) from _this_group_ where value < val
from scores
where deviceid = 1234
group by board
  • 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-08T19:31:19+00:00Added an answer on June 8, 2026 at 7:31 pm
    SELECT scores.board, count(1) AS position
    FROM scores
    JOIN
      (SELECT board, MIN(value) AS value
       FROM scores
       WHERE deviceid = 1234
       GROUP BY board
      ) player_scores
    ON scores.board = player_scores.board
    WHERE scores.value < player_scores.value
    GROUP BY scores.board
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL high scores table for a game that shows the daily
I have a two player game which stores scores in a table. I want
I have a high scores table that stores a list of scores and dates.
I have a high scores table in my game. When the game is over,
Say I have a high score table structured like name score name score ....
I have a table I use for high scores of an iPhone game. As
I have the following used to create a dummy high score table if if
I have a NSMutableArray and it has the users high scores saved into it.
I have a table that potentially will have high number of inserts per second,
I am looking to add a (local, not online) high scores table to my

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.