order by [desc,asc]
用於對記錄進行 排序
desc為降序
asc為升序
按照工資的從低到高順序 顯示所有的員工
select *from emp order by salary;
默認為升序
修改為降序
select *from emp order by salary desc;
按照每個部門的平均工資 降序排序
select dept,avg(salary) from emp group by dept order by avg(salary) desc;
limit *******
用於限制顯示的條數
limit [start,]count
# 看看表里前三條數據
select *from emp limit 3;
# 看看表里的3-5條
select * from emp limit 2,3;
# 查看工資最高的那個人的信息
select *from emp order by salary desc limit 1;
limit 常用於 數據的分頁展示 比如騰訊新聞 的上拉加載新的而一頁
select *from emp limit 0,10; 第一頁 頁數 減1 乘以條數 得到起始位置
select *from emp limit 10,10; 第2頁
select *from emp limit 20,10; 第3頁