2020-06-06--mysql数据库查询结果的order b
2020-06-06 本文已影响0人
python小哥哥2020
大家好,我是天空之城,今天给大家带来,mysql数据库查询结果的排序和分页
建表链接,https://blog.csdn.net/littlespider889/article/details/106560626
#order by 排序语法
SELECT column name1, column name2
FROM table name1, table name2
ORDER BY column name, column name [ASCIDESC]
ASC表示升序排列,DESC表示降序排列
默认情况下是升序排列
#limit分页语法
SEL .ECT column name1, column name2
FROM table name1, table name2
LIMIT [offset,] row_ count
offset指定要返回的第一行(第一条数据)的偏移量,第一行的偏移量是0,而不是1
row_count指定要返回的最大行数
还是按照之前employee表进行练习
select * from employee order by salary;
工资按照升序排列
select * from employee order by salary desc;
降序排列
同时按照两个条件进行排序
select * from employee order by sex, salary desc;
结果如下
QQ截图20200606191401.png
继续
select * from employee limit 5;显示五条数据
分页显示
select * from employee limit 0,5;
select * from employee limit 5,5;
select * from employee limit 10,5;