Allen 2020-06-06 11:30:02 11078 0 0 0 0

如下:

--创建测试表
create table temp(id int(4),name varchar(20));
--写入数据
insert into temp values (1,"aaa");
insert into temp values (2,"bbb");
insert into temp values (3,"cccc");
insert into temp values (4,"ddd");
insert into temp values (5,"eee");
insert into temp values (6,"fff");
insert into temp values (7,"ggg");
insert into temp values (8,"hhh");
insert into temp values (9,"iii");
insert into temp values (10,"jjjj");
--实现获取行号
select @rownum:=@rownum+1 as rownum,name
from temp,(select @rownum:=0) temp
where @rownum<4

OK!


【版權聲明】
本文爲原創,遵循CC 4.0 BY-SA版權協議!轉載時請附上原文鏈接及本聲明。
原文鏈接:https://tdlib.com/am.php?t=iBJGWCO9QIuu
Tag: Mysql Mysql基础
我也要發一個   ·   返回首頁   ·   返回[Mysql]   ·   前一個   ·   下一個
歡迎評論
未登錄,
請先 [ 註冊 ] or [ 登錄 ]
(一分鍾即可完成註冊!)
返回首頁     ·   返回[Mysql]   ·   返回頂部