![]() |
| |||
| Hi, I'm working on a big scoreboard which I'm hoping to split into several pages. My question is: Is there a simple way to take a column value and select the 10 values higher than it and the 10 values lower than it from the table using mysql? Here's my query so far in case you want to have a look at it: (This just selects all scores) SELECT records.recordID, max(records.score) as score, records.playerID, players.name AS playername, teams.name AS teamname, (SELECT SUM(score) FROM records WHERE teamID=teams.teamID) AS teamscore FROM records LEFT JOIN players ON players.playerID = records.playerID LEFT JOIN teams ON teams.teamID = records.teamID GROUP BY records.playerID ORDER BY records.score DESC Thanks for any help! Ciarán |
| |||
| Ciaran wrote: > Hi, > I'm working on a big scoreboard which I'm hoping to split into several > pages. My question is: > Is there a simple way to take a column value and select the 10 values > higher than it and the 10 values lower than it from the table using > mysql? > > Here's my query so far in case you want to have a look at it: (This > just selects all scores) > Select * from ( SELECT records.recordID, max(records.score) as score, records.playerID, players.name AS playername, teams.name AS teamname, (SELECT SUM(score) FROM records WHERE teamID=teams.teamID) AS teamscore FROM records LEFT JOIN players ON players.playerID = records.playerID LEFT JOIN teams ON teams.teamID = records.teamID GROUP BY records.playerID ORDER BY records.score DESC ) tmp where tmp.score between [somescore]+10 and [somescore]-10; > > Thanks for any help! > Ciarán yw. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |