如下:
--创建测试表 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基础