排序
-- order by 字段
-- asc 从小到大排序,既升序
--desc 从大到小排序 ,既降序
select * from students where (age between 18 and 40)order by age 排序默认从小到大
select * from students where (age between 18 and 40)order by age asc
select * from students where (age between 18 and 40)order by age desc 排序从大到小
--查询年龄在 18 到 34 之间的女性,身高从高到矮的排序
select * from students where age between 18 and 40 and gender = "女" order by height desc
-- order by 多个字段
--查询年龄在18到34岁之间的的女性,身高从高到矮排序,如果升高相同的情况下按照年龄从小到大排序
select * from students where age between 18 and 40 and gender = "女" order by height desc,age desc,id desc
--年龄从小到大,身高从高到小
select * from students order by asc,hight desc
网友评论