当前位置:Gxlcms > 数据库问题 > 走入计算机的第四十一天(数据库2表记录的操作)

走入计算机的第四十一天(数据库2表记录的操作)

时间:2021-07-01 10:21:17 帮助过:2人阅读

技术分享

      select  组字段名,sum(数字[int]) from order_menu group by 组字段名 having 条件;

技术分享

 

          /* having 和 where两者都可以对查询结果进行进一步的过滤,差别有:             <1>where语句只能用在分组之前的筛选,having可以用在分组之后的筛            选; <2>使用where语句的地方都可以用having进行替换 <3>having中            可以用聚合函数,where中就不行。 */

  聚合函数:

    统计个数count:

      select count(字段名) from ExamResult;

技术分享

      select count(字段名) from ExamResult where 条件;

    满足条件的行进行内容和 sum(字段名):

      select sum(字段名【要求数字类型】)from ExamResult;

    求取平均值avg(字段名):

      select avg(字段名【要求数字类型】)from ExamResult;

技术分享

    最大,最小 max, min:

      select max(字段名【要求数字类型】) from ExamRe;

技术分享

      select min(字段名【要求数字类型】) from ExamRe;

技术分享

 

select语句的结尾。

  limit 子句:

               select * from ExamResult limit 数字;

技术分享

      select * from ExamResult limit 数字,数字;

技术分享

     regexp使用:

     select * from employee where emp_name regexp  ‘^yu‘;     以什么开头

技术分享

 

     select * from employee where emp_name regexp  ‘yuan$‘;     以什么结尾

     select * from employee where emp_name regexp  ‘m{2}‘;      取几个

 

从大到小:

技术分享

取最大

技术分享

 

走入计算机的第四十一天(数据库2表记录的操作)

标签:rom   max   esc   语句   style   数字类型   数据   创建   一个   

人气教程排行