Home >Database >Mysql Tutorial >Mysql implements two methods to add serial numbers to simple query results
The example of this article describes the mysql simple method of adding serial numbers to query results. Share it with everyone for your reference, the details are as follows:
First method:
select (@i:=@i+1) as i,table_name.* from table_name,(select @i:=0) as it
Second method:
set @rownum=0; select @rownum:=@rownum+1 as rownum, t.username from auth_user t limit 1,5;
The above is the detailed content of Mysql implements two methods to add serial numbers to simple query results. For more information, please follow other related articles on the PHP Chinese website!