Insert a row no in new column in MySQL

Add a row no. in new column

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

Related posts

One Thought to “Insert a row no in new column in MySQL

  1. Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    Commenter avatars come from Gravatar.

Leave a Comment