mysql sorting and ranking statement

前端 未结 3 955
臣服心动
臣服心动 2021-01-16 16:49

I need some help in mysql statement Ive table1 with 7 column and table 2 with 8 column the extra column named ranking , my statement should be like select all from table 1

3条回答
  •  [愿得一人]
    2021-01-16 17:47

    INSERT INTO table2
      SELECT @rank := @rank + 1, table1.* FROM table1
      JOIN( SELECT @rank := 0 ) AS init
      ORDER BY number_of_users DESC
    

提交回复
热议问题