插入数据
insert into student values(0,'2024-02-25 10:10:10','赵灵儿','123',
'15612345678',16,'女','逍遥哥哥,你终于找到我了。');
insert into student values(0,'2024-02-25 10:10:10','王语嫣','123',
'15612345678',17,'女','慕容复,我和你不共戴天。');
insert into student values(0,'2024-02-25 10:10:10','龙姑娘','123',
'15612345678',22,'女','我想过过过儿过过的日子。');
insert into student values(0,'2024-02-25 10:10:10','杨过','123',
'15612345678',18,'男','一遇杨过误终身。');
insert into student values(0,'2024-02-25 10:10:10','杨逍','123',
'15612345678',27,'男','杨过跟程英的大儿子。');
insert into student (userName,age,introduce)values('黄衣女子',26,'杨过与龙姑娘的大女儿。');
查询语句
SELECT * FROM student where userName like '杨_';
SELECT * FROM student where userName like '杨%';
SELECT * FROM student where introduce like '%大%';
select * from student where pwd is not null;
select * from student where age between 22 and 30;
select * from student where createDate BETWEEN '2024-02-21 00:00:00' and '2024-02-25 00:00:00';
select * from student where userName in ('赵灵儿','杨过','龙姑娘');
聚合函数
#聚合函数5个,数量count(x)最大值max(x),最小值(x),平均数(x),求和(x)
select count(*) '所有成年人数量' from student where age>=18;
select max(*) '最大年级',min(age) '最小年龄' from student;
select avg(*) '平均年龄' from student;
select sum(*) '总年龄' from student;
select avg(*) 'avg出的总年龄',sum(age)/(select count(*) from student) '计算出的' from student;
标签:语句,10,02,2024,student,MySQL,DQL,where,select
From: https://blog.csdn.net/2301_80888276/article/details/137116209