美文网首页
9.mysql排序

9.mysql排序

作者: Aries蓝 | 来源:发表于2019-11-08 16:10 被阅读0次

    排序 

    -- 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

    相关文章

      网友评论

          本文标题:9.mysql排序

          本文链接:https://www.haomeiwen.com/subject/fucwbctx.html