Home >Database >Mysql Tutorial >Mysql implements two methods to add serial numbers to simple query results

Mysql implements two methods to add serial numbers to simple query results

怪我咯
怪我咯Original
2017-03-30 10:06:252810browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn