mysql如何指定查詢一張表的最后5行記錄和最前5行記錄?
select * from student limit 5;
select * from student limit 0,5;
select * from student order by id asc limit 5;
前五條記錄的查詢語(yǔ)句。
查詢后5條,注意結(jié)果為倒序排序,要使用desc
select * from student order by id desc limit 5
select * from student limit m,n;
返回m+1到m+n行記錄,m代表開始的下標(biāo),n代表查找的結(jié)果數(shù),將返回n行結(jié)果
select * from student limit 2,8; 返回3到10行記錄