模糊查询:
like 运算符
通配符:%——代表0-n个任意字符
- ——代表单个任意字符
注意:只有char、varchar、text类型才能使用
例子:
select * from student where name like '刘%'
select * from student where name like '%建%'
select * from student where name like '%娟'
聚合函数:对数据库中数据进行统计计算并给出结果
sum max/min avg count
例子:1.求语文课总成绩
2.求语文课的最高分和最低分
3.求语文课的平均成绩
4.求语文课考试记录条数
select sum(exam) as 语文课总成绩 from exam where subjectID=1;
select max(exam) as 语文课最高分 min(exam) as 语文课最低分 from exam where subjectID=1;
select avg(exam) as 语文课平均分 from exam where subjectID=1;
select count (exam) as 数学成绩记录数 from exam where subjectID=1;
最后
以上就是纯真薯片最近收集整理的关于MySQL 数据库 模糊查询和聚合函数的全部内容,更多相关MySQL内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复