Mysql update a column with row no

Update a column with record row no in MySQL

  1. Execute the below query in Mysql to update an row no. in the specified column

 

My Sql Query Example 

SET @pos := 0
UPDATE userinfo SET fuserid = ( SELECT @pos := @pos + 1 ) ORDER BY updated_at DESC

  1. @pos -> Variable Name
  2. userinfo -> Table Name
  3. fuserid -> Column Name

 

 

Advertisements