The example in this article describes the simple method of adding serial numbers to query results in MySQL. Share it with everyone for your reference, the details are as follows:
First method:
The code is as follows:
select (@i:=@i 1) as i,table_name.* from table_name,(select @i:=0) as it
set @rownum=0; select @rownum:=@rownum+1 as rownum, t.username from auth_user t limit 1,5;
Readers who are interested in more MySQL-related content can check out the special topics on this site: "A Complete Collection of MySQL Log Operation Skills", "A Summary of MySQL Transaction Operation Skills", "A Complete Collection of MySQL Stored Procedure Skills", and "A Summary of MySQL Database Lock Related Skills" 》and《Summary of commonly used functions in MySQL》
I hope this article will be helpful to everyone in MySQL database planning.