Here’s a way to do it:
SET @r=0;
UPDATE table SET Ranking= @r:= (@r+1) ORDER BY Score DESC;
/* use this if you just want to pull it from the db, but don't update anything */
SET @r=0;
SELECT *, @r:= (@r+1) as Ranking FROM table ORDER BY Score DESC;
More Related Contents:
- Using LIMIT within GROUP BY to get N results per group?
- MySQL, update multiple tables with one query
- UPDATE multiple rows with different values in one query in MySQL
- Multiple Updates in MySQL
- mysql update column with value from another table
- update multiple rows using limit in mysql?
- MySQL/SQL: Update with correlated subquery from the updated table itself
- What are differences between INSERT and UPDATE in MySQL?
- MySql – Way to update portion of a string?
- MySQL UPDATE syntax with multiple tables using WHERE clause
- The best way to remove value from SET field?
- Update MySQL with if condition
- Update multiple rows with multiple ‘where’ clauses for each individual row
- How can I tell when a MySQL table was last updated?
- MySQL DELETE FROM with subquery as condition
- SELECT / GROUP BY – segments of time (10 seconds, 30 seconds, etc)
- Is it possible to query a tree structure table in MySQL in a single query, to any depth?
- MySQL: Error Code: 1118 Row size too large (> 8126). Changing some columns to TEXT or BLOB
- What’s the difference between comma separated joins and join on syntax in MySQL? [duplicate]
- Determine Rank based on Multiple Columns in MySQL
- Checking multiple columns for one value
- What is better in MYSQL count(*) or count(1)?
- How to get the count of each distinct value in a column? [duplicate]
- How to enable INNODB in mysql
- Bash script to insert values in MySQL
- MySQL GROUP BY DateTime +/- 3 seconds
- How do I lag columns in MySQL?
- How to get multiple records against one record based on relation?
- SQL query to check if a name begins and ends with a vowel
- How to use a user variables in MySQL LIKE clause?