0

I have a database with column as points,ranking and some others. When I change the points in the database is it possible to rank all the records based on updated data. I am not entering ranks it should be calculated every time when I change the Points column.

Jeff Foster
  • 43,770
  • 11
  • 86
  • 103
jACOB
  • 123
  • 2
  • 5
  • 12
  • possible duplicate of [Mysql rank function](http://stackoverflow.com/questions/3333665/mysql-rank-function) and many many others – Johan May 31 '11 at 12:30
  • Alternatively to a search like: http://stackoverflow.com/search?q=[mysql]+rank – Johan May 31 '11 at 12:34

1 Answers1

0

I'd suggest do not do any calculations in the DB, it should be done at the Sever. You may do (on MYSQL):

SELECT points FROM TABLE ORDER BY points DESC LIMIT 50;

Then on the server you have a descending order list of points with each you can associate a Rank.

DB is best kept as away as possible from calculations.

check123
  • 1,989
  • 2
  • 22
  • 28
  • But i have one more column name as Ranking which holds the ranking of teams based on points so how will i update the rankings once points are changed – jACOB May 31 '11 at 12:57
  • Remove that coloumn. You can always populate ranking after fetching points from the server. – check123 May 31 '11 at 13:51