1

我有两个 JOIN 查询,它们给出的输出列是Id. 如何找到Id查询 1 返回但查询 2 未返回的所有值?

select Id from Table1 join Table2;

select Id from Table2 join Table3;
4

2 回答 2

6
SELECT id FROM dbo.Table1 INNER JOIN dbo.Table2 ON ...
EXCEPT
SELECT id FROM dbo.Table2 INNER JOIN dbo.Table3 ON ...;
于 2013-10-03T20:52:33.573 回答
0

试试这个:

select Id from Table1 join Table2
union
select Id from Table2 join Table3
于 2013-10-08T11:03:55.837 回答