@@ -9,3 +9,38 @@ select * from t_employee2 WHERE (sal, job) = (
9
9
select sal,job from t_employee2 where ename = ' smith' );
10
10
```
11
11
#### 我感觉可以用join写出来,但是感觉比直接用WHERE的子查询更复杂,研究了很久emmmmm,但没研究出来该怎么写(害羞),老师可以讲讲吗?:)
12
+
13
+ #### 后面我通过看书复习知道了怎么写了 | 开心:)
14
+ ##### 第一个query可以这样
15
+ ** 执行命令如下:**
16
+
17
+ ``` SQL
18
+ select t1 .deptno ,t1 .empno ,t1 .ename ,t1 .job ,t1 .MGR ,t1 .Hiredate ,t1 .sal ,t1 .comm # 挑选显示的内容
19
+ from t_employee2 t1 inner join t_employee2 t2
20
+ on t1 .sal > t2 .sal and (t2 .ename = ' SMITH' ); # inner join 的条件
21
+
22
+ select * from t_employee2; # 显示表t_employee2的所有记录
23
+
24
+ select * from t_employee2 WHERE sal > (
25
+ select sal from t_employee2 WHERE ename= ' SMITH' ); # 第一个query
26
+ ```
27
+ ##### 执行上面SQL语句结果显示如图所示:
28
+ ![ ] ( https://github.com/BiubiuOoo/Homework-of-MySQL/blob/master/images/31.png?raw=true )
29
+
30
+ ##### 第二个query可以这样
31
+ ** 执行命令如下:**
32
+
33
+ ``` SQL
34
+ select t1 .deptno ,t1 .empno ,t1 .ename ,t1 .job ,t1 .MGR ,t1 .Hiredate ,t1 .sal ,t1 .comm # 挑选显示的内容
35
+ from t_employee2 t1 inner join t_employee2 t2
36
+ on (t1 .sal = t2 .sal and (t2 .ename = ' SMITH' )) AND (t1 .job = t2 .job and (t2 .ename = ' SMITH' )); # inner join 的条件
37
+
38
+ select * from t_employee2 WHERE (sal, job) = (
39
+ select sal,job from t_employee2 where ename = ' smith' ); # 第一个query
40
+
41
+ select * from t_employee2; # 显示表t_employee2的所有记录
42
+ ```
43
+ ##### 执行上面SQL语句结果显示如图所示:
44
+ ![ ] ( https://github.com/BiubiuOoo/Homework-of-MySQL/blob/master/images/32.png?raw=true )
45
+
46
+
0 commit comments