我有一堆子查询,每个子查询都返回一堆带有两个 ID 字段的记录。我需要返回所有子查询中存在的所有 ID 对的列表。我在想我可以做这样的事情:
SELECT Q1.V1, Q1.V2
FROM ( [SUBQUERY1] ) AS Q1
INNER JOIN ( [SUBQUERY2] ) AS Q2 ON Q2.V1 = Q1.V1 AND Q2.V2 = Q1.V2
INNER JOIN ( [SUBQUERY3] ) AS Q3 ON Q3.V1 = Q2.V1 AND Q3.V2 = Q2.V2
INNER JOIN ( [SUBQUERY4] ) AS Q4 ON Q4.V1 = Q3.V1 AND Q4.V2 = Q3.V2
有没有更好的办法?