diff --git "a/08 \345\256\230\346\226\207\350\257\232/2023.03.1 \345\205\263\350\201\224\346\237\245\350\257\242.md" "b/08 \345\256\230\346\226\207\350\257\232/2023.03.1 \345\205\263\350\201\224\346\237\245\350\257\242.md" new file mode 100644 index 0000000000000000000000000000000000000000..023f74facc0256fc6738a1a6ec72530cb4e1d985 --- /dev/null +++ "b/08 \345\256\230\346\226\207\350\257\232/2023.03.1 \345\205\263\350\201\224\346\237\245\350\257\242.md" @@ -0,0 +1,301 @@ + + +# 笔记 + +Avg()平均值 Sum()求和 Max()最大值 + +Min()最小值 count()统计记录器 + +count(*)统计全部,count*(字段)统计非null的值 + +### 关联查询 + +关联查询:两个或更多个表一起查询。 + +又称为联合查询,多表查询 + +1、关联查询的结果一共有7种: + +两个表的记录分为四种: + +①A表中的记录能在B表中找到对应的记录 + +②A表中的记录在B表中找不到对应的记录 + +③B表中的记录可以在A表找到对应的记录 + +④B表中的记录在A表中找不到对应的记录 + +(1)A∩B ①③ + +(2)A ①② + +(3)A-A∩B ② + +(4)B ③④ + +(5)B-A∩B ④ + +(6)A∪B ①②③④ + +(7)A∪B-A∩B **②④** + +2.两个表要一起查询,要有前提条件:有关联 + +内连接:a inner join b on a.字段=b.字段 ab相同数据 + +左全连接:a left join b on a.字段=b.字段 where a.字段 is null 不重复的a数据 + +右全连接:a right join b on a.字段=b.字段 where b.字段 is null 不重复的b数据 + +左连接:a left join b on a.字段=b.字段 全a数据 + +右连接:a right join b on a.字段=b.字段 全b数据 + +# 作业 + +表(一)Student (学生表) + +~~~ mysql +create table Student( +Sno varchar (20) not null primary key, +Sname varchar (20) not null, +Ssex varchar (20) not null, +Sbirthday datetime, +Class varchar (20) +); + +~~~ + + + +表(二)Course(课程表) + +~~~ mysql +create table Course( +Cno varchar (20) not null primary key, +Cname varchar (20) not null, +Tno varchar (20) not null, +foreign key(Tno) references Teacher(Tno) +); + +~~~ + + + +表(三)Score(成绩表) + +~~~ mysql +create table Score( +Sno varchar (20) not null, +foreign key(Sno) references Student(Sno), +Cno varchar (20), +foreign key(Cno) references Course(Cno), +Degree Decimal(4,1) +); + +~~~ + + + +表(四)Teacher(教师表) + +~~~ mysql +create table Teacher( +Tno varchar (20) not null primary key, +Tname varchar (20) not null, +Tsex varchar (20) not null, +Tbirthday datetime, +Profvarchar (20), +Depart varchar (20) not null +); + +~~~ + + + +1,查询所有学生,都学了哪些课程,要显示学生信息和课程信息/ + +~~~ mysql +select score.Sno,score.Cno from score INNER JOIN course INNER JOIN student on score.Sno=student.Sno and course.Cno=score.Cno; +~~~ + + 2,查询没有学生的教师的所有信息 + +表(一)Student + +~~~ mysql +INSERT INTO student VALUES + ('108', '曾华', '男', '1977-9-1', '95033' ), + ('105', '匡明', '男', '1975-10-2', '95031' ), + ('107', '王丽', '女', '1976-1-23', '95033' ), + ('101', '李军', '男', '1976-2-20', '95033' ), + ('109', '王芳', '女', '1975-2-10', '95031' ), + ('103', '陆君', '男', '1974-6-3', '95031' ); + +~~~ + + + +表(二)Course + +~~~ sql +INSERT INTO course VALUES +('3-105','计算机导论','825'), +('3-245','操作系统','804'), +('6-166','数字电路','856'), +('9-888','高等数学','831'); + +~~~ + + + +表(三)Score + +~~~ sql +INSERT INTO score VALUES +('103','3-245','86'), +('105','3-245','75'), +('109','3-245','68'), +('103','3-105','92'), +('105','3-105','88'), +('109','3-105','76'), +('101','3-105','64'), +('107','3-105','91'), +('108','3-105','78'), +('101','6-166','85'), +('107','6-166','79'), +('108','6-166','81'); + +~~~ + + + +表(四)Teacher + +~~~ sql +INSERT INTO teacher VALUES + ('804', '曾华', '男', '1977-9-1', '95033' ), + ('856', '匡明', '男', '1975-10-2', '95031' ), + ('825', '王丽', '女', '1976-1-23', '95033' ), + ('831', '李军', '男', '1976-2-20', '95033' ); + +~~~ + + + +查询Score表中的最高分的学生学号和课程号。 + +~~~ sql +select Sno,Cno from Score; +~~~ + + + +查询所有学生的Sname、Cno和Degree列。 + +~~~ sql + SELECT student.Sname,score.Cno,score.Degree FROM student INNER JOIN score ON student.Sno=score.Sno; + +~~~ + + + +查询所有学生的Sno、Cname和Degree列。 + +~~~ sql +SELECT score.Sno,course.Cname,score.Degree from course INNER JOIN score on score.Cno=course.Cno; +~~~ + + + +查询所有学生的Sname、Cname和Degree列。 + +~~~ sql +SELECT student.Sname,course.Cname,score.Degree FROM student INNER JOIN course INNER JOIN score on student.Sno=score.Sno and course.Cno=score.Cno; +~~~ + + + +查询“95033”班学生的平均分。 + +查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。 + +~~~ sql +select * from Score where Cno='3-105' and degree>(select degree from score where sno='109' and cno='3-105'); +~~~ + + + +查询score中选学多门课程的同学中分数为非最高分成绩的记录。 + +查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。 + +~~~ sql +select * from score INNER JOIN student INNER JOIN course on score.Sno=student.Sno and course.Cno=score.Sno where Degree>(score.Sno='109') and score.Cno='3-105'; +~~~ + +查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列。 + +查询“张旭“教师任课的学生成绩。 + +~~~ sql +select Score.degree from Score inner join Course inner join Teacher ON +Score.Cno=Course.Cno and Course.Tno=Teacher.Tno where Teacher.Tname='张旭'; + +~~~ + + + +查询选修某课程的同学人数多于5人的教师姓名。 + +查询出“计算机系“教师所教课程的成绩表。 + +~~~ sql +SELECT score.Degree FROM teacher INNER JOIN course INNER JOIN score on teacher.Tno=course.Tno and course.Cno=score.Cno where teacher.Depart='计算机系'; +~~~ + + + +查询“计算机系”与“电子工程系“不同职称的教师的Tname和Prof。 + +查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。 + +查询选修编号为“3-105”且成绩高于选修编号为“3-245”课程的同学的Cno、Sno和Degree. + +查询成绩比该课程平均成绩低的同学的成绩表。 + +查询所有任课教师的Tname和Depart. + +查询所有未讲课的教师的Tname和Depart. + +查询“男”教师及其所上的课程。 + +~~~ sql +select Tname,Cname from Teacher inner join Course on +Teacher.Tno=Course.Tno +where +Tsex='男'; + +~~~ + + + +查询最高分同学的Sno、Cno和Degree列。 + +查询和“李军”同性别的所有同学的Sname. + +查询和“李军”同性别并同班的同学Sname. + +查询所有选修“计算机导论”课程的“男”同学的成绩表。 + +~~~ sql +select Degree from Course inner join Score inner join Student on +Course.Cno=Score.Cno and Score.Sno=Student.Sno +where +Ssex='男' +and +Cname=(select Cname from Course where Cname='计算机导论') ; + +~~~ + diff --git "a/08 \345\256\230\346\226\207\350\257\232/20230222 DDL\345\222\214DML_\345\273\272\350\241\250\344\270\216\345\241\253\345\200\274\344\275\234\344\270\232.md" "b/08 \345\256\230\346\226\207\350\257\232/20230222 DDL\345\222\214DML_\345\273\272\350\241\250\344\270\216\345\241\253\345\200\274\344\275\234\344\270\232.md" index a488268a2c6c30a0065c9411f3be5a7b68188090..ab0aca0407a4e12eb8d5d17173c266775fee6714 100644 --- "a/08 \345\256\230\346\226\207\350\257\232/20230222 DDL\345\222\214DML_\345\273\272\350\241\250\344\270\216\345\241\253\345\200\274\344\275\234\344\270\232.md" +++ "b/08 \345\256\230\346\226\207\350\257\232/20230222 DDL\345\222\214DML_\345\273\272\350\241\250\344\270\216\345\241\253\345\200\274\344\275\234\344\270\232.md" @@ -242,7 +242,7 @@ SELECT `name` FROM pet where `owner` IS null; 8、 查询已经死了的cat的姓名,主人,以及去世时间; ~~~ mysql -select `name`,`owner`,death from pet WHERE species='Cat'; +select `name`,`owner`,death from pet WHERE death=2010; ~~~ @@ -279,7 +279,7 @@ create table department( depid int primary key auto_increment, depname char(10) not null unique key, deinfo varchar(200) -); +); ``` B. 雇员表(employee):雇员编号(empid),姓名(name),性别(sex),职称(title),出生日期(birthday),所在部门编号(depid);其中 @@ -289,15 +289,15 @@ B. 雇员表(employee):雇员编号(empid),姓名(name),性 * ​ 性别默认为男; ```mysql -alter table Teacher convert to character set utf8; -create table employee ( - empid int primary key auto_increment, - name varchar(10) not null, - sex enum('男','女') not null default '男', - title varchar(10), - birthday date, - depid int foreign key references department(depid) -); +create table employee( +empid int primary key, +name varchar(10), +sex enum('男','女') not null default'男', +title varchar(10), +birthday date, +depid int, +CONSTRAINT department foreign key(depid) references department(depid) +); ``` C. 工资表(salary):雇员编号(empid),基本工资(basesalary),职务工资(titlesalary),扣除(deduction)。其中雇员编号为主键。 @@ -311,7 +311,6 @@ basesalary double, titlesalary double, deduction double, foreign key(empid) references employee(empid) - ); ~~~ diff --git "a/08 \345\256\230\346\226\207\350\257\232/20230223 \345\237\272\347\241\200\346\237\245\350\257\242_\350\277\220\347\256\227\347\254\246.md" "b/08 \345\256\230\346\226\207\350\257\232/20230223 \345\237\272\347\241\200\346\237\245\350\257\242_\350\277\220\347\256\227\347\254\246.md" new file mode 100644 index 0000000000000000000000000000000000000000..36e15ef9820cbca4e8dd918d8958eeb47a66ca68 --- /dev/null +++ "b/08 \345\256\230\346\226\207\350\257\232/20230223 \345\237\272\347\241\200\346\237\245\350\257\242_\350\277\220\347\256\227\347\254\246.md" @@ -0,0 +1,253 @@ +# 笔记 + +## DQL + +结果去重 + +一个列里数据出现了好几次重复的值时,如果只想保留一个,就可以去重。 + +~~~mysql +select distinct 字段列表 from 表名称 where 条件; +-- distinct 只能出现在第一个字段前面 +~~~ + +### 别名 + +~~~ mysql +select 字段名 [as] 别名 from 表名; +-- as 可有可无 +-- 别名的引号可以省略 +~~~ + +列的别名有空格时,加双引号,没有空格双引号可加可不加 + +表的别名不用加双引号,表的别名不能有空格 + +~~~ mysql +select * from 表明 as 别名; +~~~ + +### 模糊查询 + +### like + +%;代表任意个字符 + +—;代表一个字符,两个下划线就是两个字符 + +### 逻辑查询 + +### xor + +两者只能满足其中一个,不能同时满足,不能同时不满足。 + +## 运算符 + +div (保留整数部分) + +安全等于 <=> 可以用于null的运算 + +模,% (取余) + +不等于,!= 或 <> 不能用于null判断 + +## 区间 + +区间范围 + +~~~mysql +between x and y +~~~ + +不在这区间 + +~~~sql +not between x and y +~~~ + +集合范围 + +~~~sql +in (x,y,z),有其中一个就行 +not in(x,y,z),不在这其中 +~~~ + + + + + +## 第1题:员工表 + +```mysql +drop table if exists `employee`; +#创建employee表 +CREATE TABLE employee( + id INT, + `name` VARCHAR(20), + sex VARCHAR(20), + tel VARCHAR(20), + addr VARCHAR(50), + salary FLOAT +); + +#添加信息 +INSERT INTO employee(id,`name`,sex,tel,addr,salary)VALUES +(10001,'张一一','男','13456789000','广东韶关',10010.58), +(10002,'刘小红','女','13454319000','广东江门',12010.21), +(10003,'李四','男','0751-1234567','广东佛山',10040.11), +(10004,'刘小强','男','0755-5555555','广东深圳',15010.23), +(10005,'王艳','男',NULL,'广东广州',14050.16); +``` + + + +| **id** | **name** | **sex** | **tel** | **addr** | **salary** | +| ------ | -------- | ------- | ------------ | -------- | ---------- | +| 10001 | 张一一 | 男 | 13456789000 | 广东韶关 | 10010.58 | +| 10002 | 刘小红 | 女 | 13454319000 | 广东江门 | 12010.21 | +| 10003 | 李四 | 男 | 0751-1234567 | 广东佛山 | 10040.11 | +| 10004 | 刘小强 | 男 | 0755-5555555 | 广东深圳 | 15010.23 | +| 10005 | 王艳 | 女 | NULL | 广东广州 | 14050.16 | + +**要求1:**查询出薪资在12000~13000之间的员工信息。 + +~~~ mysql +select * from employee where salary BETWEEN 12000 and 13000; +~~~ + + + +**要求2:**查询出姓“刘”的员工的工号,姓名,家庭住址。 + +~~~ masql +select id,`name`,addr from employee where `name` LIKE '%刘%'; +~~~ + +**要求3:**将“李四”的家庭住址改为“广东韶关” + +~~~ mysql +UPDATE employee set addr='广东韶关' where `name`='李四'; +~~~ + +**要求4:**查询出名字中带“小”的员工 + +~~~ mysql +SELECT * from employee where `name` LIKE '%小%'; +~~~ + +**要求5:**查询出薪资高于11000的男员工信息 + +~~~ mysql +select * from employee where salary > 11000 and sex='男'; +~~~ + +**要求6:**查询没有登记电话号码的员工 + +~~~ mysql +select * from employee where tel is null; +~~~ + +**要求7:**查询薪资高于12000或者家是广东深圳、广州的男员工 + +~~~ mysql +select * from employee where salary>12000 or addr='广东深圳' or sex='男'; +~~~ + +**要求8:**查询每个员工的年薪,显示“姓名、年薪” + +```mysql +select salary*12 年薪 , `name` 姓名 from employee; +``` + +## 第2题:国家信息表 + +countries_info表中存储了国家名称、所属大陆、面积、人口和 GDP 值。 + +```mysql +DROP TABLE IF EXISTS `countries_info`; +CREATE TABLE `countries_info`( + `name` VARCHAR(100), + `continent` VARCHAR(100), + `area` INT, + population INT, + gdp BIGINT +); + +INSERT INTO countries_info VALUES +('Afghanistan','Asia',652230,25500100,20343000000), +('Albania','Europe',28748,2831741,12960000000), +('Algeria','Africa',2381741,37100000,188681000000), +('Andorra','Europe',468,78115,3712000000), +('Angola','Africa',1246700,20609294,100990000000); +``` + +表数据样例: + +```mysql ++-------------+-----------+---------+------------+--------------+ +| name | continent | area | population | gdp | ++-------------+-----------+---------+------------+--------------+ +| Afghanistan | Asia | 652230 | 25500100 | 20343000000 | +| Albania | Europe | 28748 | 2831741 | 12960000000 | +| Algeria | Africa | 2381741 | 37100000 | 188681000000 | +| Andorra | Europe | 468 | 78115 | 3712000000 | +| Angola | Africa | 1246700 | 20609294 | 100990000000 | ++-------------+-----------+---------+------------+--------------+ +``` + +**要求1:** 查询大国 的国家名称、人口和面积。 + +如果一个国家满足下述两个条件之一,则认为该国是 大国 : + +- 面积至少为 300万平方公里(即,3000000 km2) + +- 人口至少为 2500 万(即 25000000) + + ~~~ mysql + select `name`,area,population from `countries_info` where area >= 3000000 or population >= 25000000; + ~~~ + +**要求2:**查询属于亚洲的国家名称、所属大陆、面积、人口和 GDP 值 + +~~~ mysql +SELECT * from `countries_info` where continent='asia'; +~~~ + +**要求3:**查询国土面积不足1万平方公里且人口不走10万人的国家信息 + +~~~ mysql +select * from `countries_info` where area < 10000 or population < 100000; +~~~ + + + +**要求4:**查询国家名字中包含“o“字母的国家信息 + +~~~ mysql +select * from `countries_info` where `name` like '%o%'; +~~~ + +**要求5:**查询GDP值超过10000000000的国家信息 + +~~~ mysql +select * from `countries_info` where gdp>10000000000; +~~~ + +**要求6:**查询每个国家的人均贡献GDP值(GDP/人口总数)并显示为“国家名、人口、GDP值、人均贡献GDP值” + +~~~ mysql +select `name` 国家名,population 人口,gdp GDP值,gdp/population 人均贡献GDP值 from `countries_info`; +~~~ + +**要求7:**查询人均贡献GDP值低于1000的国家信息。 + +~~~ mysql +select * from `countries_info` where gdp/population<1000; +~~~ + +**要求8:**查询每个国家的人均国土面积(面积/人口总数)并显示为“国家名、面积、人口、人均国土面积值” + +```mysql +select `name` 国家名,area 面积,population 人口, area/population 人均国土面积值 from `countries_info`; +``` + diff --git "a/08 \345\256\230\346\226\207\350\257\232/20230308 \345\255\220\346\237\245\350\257\242.md" "b/08 \345\256\230\346\226\207\350\257\232/20230308 \345\255\220\346\237\245\350\257\242.md" new file mode 100644 index 0000000000000000000000000000000000000000..e12d2b2e94927614868bfde1c8c8aba1ed000951 --- /dev/null +++ "b/08 \345\256\230\346\226\207\350\257\232/20230308 \345\255\220\346\237\245\350\257\242.md" @@ -0,0 +1,200 @@ +# 笔记 + +7大字句 +1. from : 从哪些表中筛选 +2. on : 关联多表查询时,去除笛卡尔积 +3. where : 从表中筛选的条件 +4. group by : 分组依据 +5. having:在统计结果中再次筛选 +6. order by: 排序 +7. limit:分页 +必须按照(1)~(7)的顺序 编写字句 + +having子句也写条件 +where的条件是针对原表中的记录的筛选。where后面不能出现分组函数。 +having子句是对统计结果(分组函数计算后)的筛选。having可以加分组函数。 + +### 子查询 + +嵌套在其他sql语句中的查询语句 + +子查询通常先运行,所以要用()包括起来 + +子查询的运行结果可以作为其语句条件,数据源等 + +## select 1 from 2 where 3 + +# 作业 + +在如图的数据表上完成以下题目 +表一 + +~~~ sql +CREATE TABLE `stuinfo` ( + `stuN0` varchar(20) NOT NULL, + `stuName` varchar(20) DEFAULT NULL, + `stuSex` varchar(10) DEFAULT NULL, + `stuAge` int(11) DEFAULT NULL, + `stuAddress` varchar(20) DEFAULT NULL, + `stuseat` int(11) DEFAULT NULL, + PRIMARY KEY (`stuN0`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +~~~ + +表二 + +~~~ sql +CREATE TABLE `stuexam` ( + `examN0` int(11) NOT NULL, + `stuN0` varchar(20) DEFAULT NULL, + `wittenExam` int(11) DEFAULT NULL, + `labExam` int(11) DEFAULT NULL, + PRIMARY KEY (`examN0`), + KEY `stuN0` (`stuN0`), + CONSTRAINT `stuexam_ibfk_1` FOREIGN KEY (`stuN0`) REFERENCES `stuinfo` (`stuN0`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +~~~ + +表三 + +~~~ sql +CREATE TABLE `stumarks` ( + `examN0` int(11) DEFAULT NULL, + `stuID` varchar(20) DEFAULT NULL, + `score` int(11) DEFAULT NULL, + KEY `examN0` (`examN0`), + CONSTRAINT `stumarks_ibfk_1` FOREIGN KEY (`examN0`) REFERENCES `stuexam` (`examN0`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +~~~ + + +添加数据 + + +1. ~~~ sql + INSERT into stuinfo VALUES ('s2501','张秋利','男',20,'美国硅谷',1),('s2502','李斯文','女',18,'湖北武汉',2),('s2503','马文才','男',18,'湖南长沙',3),('s2504','欧阳俊雄','女',21,'湖北武汉',4),('s2505','梅超风','男',16,'湖北武汉',5),('s2506','陈旋风','男',19,'美国硅谷',6); + + ~~~sql + +2. + +INSERT INTO stuExam VALUES +(1,'s2501',50,70), +(2,'s2502',60,65), +(3,'s2503',86,70), +(4,'s2504',40,80), +(5,'s2505',70,85), +(6,'s2506',85,90); + ~~~ + +3. + +~~~ sql +INSERT INTO stuMarks VALUES +(1,'s2501',88), +(2,'s2501',92), +(3,'s2501',53), +(4,'s2502',60), +(5,'s2502',99), +(6,'s2503',82); +~~~ + +1.查询出年龄比班上平均年龄大的学生的信息 + +~~~ sql +SELECT * from stuinfo where stuAge >(select avg(stuAge) from stuinfo); +~~~ + +2.查询出每个学生的学号,姓名,性别和选修课程的最高分(stuMarks) + +~~~ sql +select t.stuN0,t.stuName,t.stuSex,max(score) from stumarks s left join stuinfo t on s.stuID=t.stuN0 group by s.stuID; +~~~ + +3.查询出每个学生的学号,姓名,性别和考试平均分(stuExam) + +~~~ sql + +~~~ + +4.查询性别是男并且年龄大于等于20的学生的信息(用两种方法实现:普通查询和子查询) + +~~~ sql +SELECT * from stuinfo where stuSex='男' and stuAge>=20; + +~~~ + +~~~ sql +SELECT * from stuinfo where stuAge=(SELECT stuAge from stuinfo where stuSex='男' and stuAge>=20); + +~~~ + + + +5.查询出年龄比所有男生年龄都大的女生的信息 + +~~~ sql +SELECT * from stuinfo where stuSex='女'and stuAge> all (SELECT stuAge from stuinfo where stuSex='男'); + +~~~ + + + +6.查询出所有选修课程都及格的学生的信息 (stuMarks) + +~~~ sql +SELECT * from stuinfo LEFT JOIN stumarks on stuinfo.stuN0=stumarks.stuID WHERE score>60 GROUP BY stuid; +~~~ + + + +7.查询出参加考试的学生的信息(用表连接,in二种方法做)(stuMarks) + +~~~ sql +SELECT * from stuinfo a LEFT JOIN stumarks s on a.stuN0=s.stuID where s.score is not null; +~~~ + + + +8.查询出没有参加考试的学生的信息(用表连接,in二种方法做)(stuMarks) + +~~~ sql +SELECT * from stuinfo a LEFT JOIN stumarks s on a.stuN0=s.stuID where s.score is null; +~~~ + + + +9.将有一门成绩成绩大于90分的学生的基本信息查询出来(stuMarks) + +~~~ sql +SELECT * from stuinfo LEFT JOIN stumarks on stuinfo.stuN0=stumarks.stuID where score>90; +~~~ + + + +10.查询出平均成绩在80分以上的学生的基本信息(stuMarks) + + + +11.查询出某同学所有考试成绩比“张秋利”同学所有分数都高的学生基本信息(stuMarks) + +~~~ sql +SELECT a.* from stuinfo a LEFT JOIN stumarks s on a.stuN0=s.stuID where s.score >(SELECT score from stumarks where stuID='s2501') GROUP BY stuID; +~~~ + + + +12.查询出某同学所有考试成绩只需要比“张秋利”同学某个分数高的学生基本信息(stuMarks) + +13.查询班上比所有男生年龄都要大的女生的信息 + +~~~ sql +SELECT * from stuinfo where stuSex='女'and stuAge> all (SELECT stuAge from stuinfo where stuSex='男'); +~~~ + +14.查询出只要比某个男生年龄大的女生的信息 + +~~~ sql +select * from stuinfo where stusex = '女' and stuage > (select min(stuage) from stuinfo where stusex = '男'); +~~~ +