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