mysql排序

排序

  • 为了方便查看数据, 可以对数据进行排序
  • 语法
1
2
select * from tableName
order by line1 asc|desc,line2 asc|desc,...;
  • 将表中的所有行数据按照列1进行排序,如果某些行列1的值相同,则按照列2排序,以此类推。

  • 默认按照从小到大排序 asc。

  • asc 从小到大,升序。
  • desc 从大到小,降序。
  • 查询未删除女生信息,按id降序
1
2
3
select * from tableName
where gender=0 and isdelete = 0
order by id desc;
  • 查询未删除科目信息,按名称升序。
    1
    2
    3
    select * from subject
    where isdelete=0
    order by stite;
文章作者: Luo Jun
文章链接: /2018/04/12/mysqlsort/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Aning