手机
当前位置:查字典教程网 >编程开发 >mysql数据库 >MySQL笔记之函数查询的使用
MySQL笔记之函数查询的使用
摘要:参考表count()用来统计记录的条数复制代码代码如下:mysql>selectcount(*)fromscore;mysql>select...

参考表

MySQL笔记之函数查询的使用1

count()用来统计记录的条数

复制代码 代码如下:

mysql> select count(*) from score;

mysql> select count(*) from score where stu_id=901;

sum()求和函数

复制代码 代码如下:

mysql> select sum(grade) from score;

mysql> select id,sum(grade) from score where stu_id=901;

avg()求平均值函数

复制代码 代码如下:

mysql> select avg(grade) from score where c_name='计算机';

mysql> select c_name,avg(grade) from score group by c_name;

max()求最大值函数

复制代码 代码如下:

mysql> select c_name,max(grade) from score where c_name='英语';

mysql> select c_name,max(grade) from score group by c_name;

min()求最小值函数

复制代码 代码如下:

mysql> select c_name,min(grade) from score where c_name='中文';

mysql> select c_name,min(grade) from score group by c_name;

Concat拼接函数

复制代码 代码如下:

mysql> select Concat(c_name, '(', stu_id, ')')

-> from score order by stu_id;

【MySQL笔记之函数查询的使用】相关文章:

MySQL 字符串函数大全

MySQL里面的子查询实例

MySQL 加密/压缩函数

MySQL 查询中的分页思路的优化教程

MySQL删除数据Delete与Truncate语句使用比较

MySQL中字符串函数详细介绍

MySQL中使用case when 语句实现多条件查询的方法

MySQL数据库的23个注意事项

MySQL数据库恢复(使用mysqlbinlog命令)

MySQL将表a中查询的数据插入到表b中

精品推荐
分类导航