SET @rank:=0;
update T
set Number=@rank:=@rank+1;
UPDATE
alternative way with one statement
UPDATE T
JOIN (SELECT @rank := 0) r
SET Number=@rank:=@rank+1;
More Related Contents:
- How to find similar results and sort by similarity?
- ORDER BY alphabet first then follow by number
- If two columns are 1 then make new column
- How can I return pivot table output in MySQL?
- MySQL – Get row number on select
- Natural Sort in MySQL
- Group by clause in mySQL and postgreSQL, why the error in postgreSQL?
- Retrieving the last record in each group – MySQL
- Cast from VARCHAR to INT – MySQL
- Required to join 2 tables with their FKs in a 3rd table
- Does COUNT(*) always return a result?
- Operand Should Contain 1 Column – MySQL NOT IN
- Connect By Prior Equivalent for MySQL
- MySQL: Error Code: 1118 Row size too large (> 8126). Changing some columns to TEXT or BLOB
- How to convert all tables from MyISAM into InnoDB?
- SQL Query to show nearest date?
- How to create relationships in MySQL
- Mysql Improve Search Performance with wildcards (%%)
- Best practices for SQL varchar column length [closed]
- ALTER TABLE to add a composite primary key
- How to get the count of each distinct value in a column? [duplicate]
- What are differences between INSERT and UPDATE in MySQL?
- Set value to NULL in MySQL
- SELECT query return 1 row from each group
- MySql Single Table, Select last 7 days and include empty rows
- mysql SQL: specific item to be first and then to sort the rest of the items
- When is a timestamp (auto) updated?
- MySQL Group By Hours
- RMySQL dbWriteTable with field.types
- mySQL query to search all tables within a database for a string?