Home > Database > Mysql Tutorial > body text

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

怪我咯
Release: 2017-03-30 10:06:25
Original
2770 people have browsed it

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
Copy after login

Second method:

set @rownum=0;
select @rownum:=@rownum+1 as rownum, t.username from auth_user t limit 1,5;
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!