欢迎投稿

今日深度:

MySQL第五天,所以,优化的语句为:

MySQL第五天,所以,优化的语句为:


2022-09-07

1、Mysql中的清屏:

system clear

一般的清屏命令:clear

聚合函数

2、查询某个表中某个字段的值的个数(使用count)

以“students”表(字段有id,name,age,gender,height)为例:

select count(id) from students;

说明:select count(字段名) from 表名;

(2)统计表中的数据条数

select count*from 表名;

3、查询在约束条件下某个字段中的最大值

以“students”表为例:

select max(id) from students where gender = 'girl';

4、查询在约束条件下某个字段值的总和

以“students”表为例:

select sum(height) from students where gender = 'boy';

说明:select sum(字段名) from 表名 where 约束条件;

5、查询在约束条件下某个字段值的平均值

以“students”表为例:

select avg(height) from students where gender = 'boy';

说明:格式:select avg(字段名) from 表名 where 约束条件;

注意:如果统计某个字段中的值有NULL,则会跳过。所以,优化的语句为:

select avg(ifnull(height,0)) from students where gender = 'boy';

说明:如果为空,则设为0.

 

www.htsjk.Com true http://www.htsjk.com/Mysql/44628.html NewsArticle MySQL第五天,所以,优化的语句为: 2022-09-07 1、Mysql中的清屏: system clear 一般的清屏命令:clear 聚合函数 2、查询某个表中某个字段的值的个数(使用count) 以“students”表(字段有i...
相关文章
    暂无相关文章
评论暂时关闭