SELECT Sno,Sname,Sdept
FROM Student S1
WHERE EXISTS
(SELECT *
FROM Student S2
WHERE S2.Sdept=S1.Sdept AND
S2.Sname='刘晨');
这2张表执行的全过程是怎样的?每个表是怎样先后调用?
------解决方案--------------------------------------------------------
当s1的一个元组定下来之后, 比如
S1
| 200215123 | 王敏 | 女 | 18 | MA |
则 (SELECT *
FROM Student S2
WHERE S2.Sdept=S1.Sdept AND
S2.Sname='刘晨'
);
等同于
(SELECT *
FROM Student S2
WHERE S2.Sdept='MA' AND
S2.Sname='刘晨'
);