嗨,我正在尝试即兴发挥我的查询以获得更好的性能。是否有任何其他方式来编写我的 SQL。问题如下。
SELECT DISTINCT A.name as name,
A.gender as gender
FROM
(
SELECT *
FROM Students S,
Enrollment E,
Group1 G,
Ingroup I
WHERE S.sid = E.sid
AND S.sid = I.sid
AND I.gid = G.gid
)A,
(SELECT *
FROM Students S,
Enrollment E,
Group1 G,
Ingroup I
WHERE S.sid = E.sid
AND S.sid = I.sid
AND I.gid = G.gid
AND S.name="Andrew Peers"
) B
WHERE A.dept = B.dept
AND A.cid = B.cid
AND A.gid = B.gid;