SELECT * FROM `student` WHERE userName like '张_';
SELECT * FROM `student` WHERE userName like '刘%';
SELECT * FROM `student` WHERE pwd is null;
SELECT * FROM `student` WHERE pwd is not null;
SELECT * FROM `student` WHERE age BETWEEN 30 and 40;
SELECT * FROM `student` WHERE createDate between '2024-02-21 00:00:00' and '2024-02-23 00:00:00';
SELECT * FROM `student` WHERE userName in('张翰','刘德华','刘亦菲');
SELECT count(*) from student where pwd is not null;
SELECT max(age) '最大年龄',min(age) '最小年龄' from student;
SELECT avg(age) '平均年龄' from student;
SELECT sum(age) '总年龄' from student;
SELECT avg(age) '平均年龄',sum(age)/(SELECT count(*)from student) 'sum计算平均年龄' from student;
MySQL聚合函数的使用方法
最新推荐文章于 2024-04-27 22:54:31 发布