Home >Database >Mysql Tutorial >MySQL实现简单row_number()的模拟

MySQL实现简单row_number()的模拟

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 14:57:401407browse

无详细内容 无 set @name='';set @num=0;select r.name, r.score, @num:=if(@name=r.name,@num+1,1) rn0, @name:=r.name namesfrom new_table_test rorder by 1,2 asc

MySQL实现简单row_number()的模拟
set @name='';
set @num=0;
select r.name,
       r.score, 
       @num:=if(@name=r.name,@num+1,1) rn0,
	   @name:=r.name names
from new_table_test r
order by 1,2 asc
MySQL实现简单row_number()的模拟
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