#like用法,where 后先写查询列再写like最后匹配字符串
SELECT * FROM student where username like '杨%';
SELECT * FROM student where introduce like '%大%';
SELECT * FROM student where username like '杨_';
#范围查询 betwween--and 包括==的
SELECT * FROM student where age between 20 and 30 ;
SELECT * FROM student where createdate between '2024-02-21 00:00:00' and '2024-02-25 00:00:00';
#in 关键字的使用不建议使用关键字因为不一定走索引在百万表的数据中会很卡
SELECT * FROM student where username in ('杨过','龙姑娘');
聚合函数
#聚合函数 数量count 最大值max 最小值min 平均值avg 求和sum
SELECT count(*)'所有成年人数量' from student where age>=18;
select max (age)'最大年龄',min(age)'最小年龄'from student;
select avg (age)'平均年龄'from student;
select sum (age)'总年龄'from student;
select avg (age)'avg出的总年龄',sum(age)/(select count(*) from student ) '计算出的'from student;