Mysql基本命令

查询语句基本命令

排序

  • order by
    • asc 倒叙(从大到小)select score from student order by score asc;根据分数从大到小排序
    • desc顺序(从小到大)select score from student order by score asc;根据分数从小到大排序

分页

  • limit select score from student order by score asc limit 5;只展示前5条数据

截取数据

  • offset select score from student order by score asc limit 5 offset 2;从第3条(不包含第2条)数据开始选取,选取5条数据

去重

  • distinct SELECT distinct role from Employees; 查询所有的角色,并去重(重复的保留一项)
posted @ 2021-08-19 16:42  Hiraly  阅读(44)  评论(0编辑  收藏  举报