Join 配置单元:不在子查询联接中

Join 配置单元:不在子查询联接中,join,hive,subquery,Join,Hive,Subquery,我正在寻找一种方法,从一个表中选择在另一个表中不存在的所有值。这需要在两个变量上完成,而不是一个 select * from tb1 where tb1.id1 not in (select id1 from tb2) and tb1.id2 not in (select id2 from tb2) 我不能使用子查询。它只需要使用联接来完成 我试过这个: select * from tb1 full join tb2 on tb1.id1=tb2.id1 and tb1.id2=tb2.i

我正在寻找一种方法,从一个表中选择在另一个表中不存在的所有值。这需要在两个变量上完成,而不是一个

select * from tb1 
where tb1.id1 not in (select id1 from tb2) 
and tb1.id2 not in (select id2 from tb2)
我不能使用子查询。它只需要使用联接来完成

我试过这个:

select * from tb1 full join tb2 on
tb1.id1=tb2.id1 and tb1.id2=tb2.id2
在条件中只有一个变量,而不是两个变量时,这可以正常工作。
请建议一些解决方案。

由于您希望从tb1获取所有数据,而tb2上的id1列和id2列没有公共数据,因此可以在表tb1上使用左外部联接。差不多

SELECT tb1.* FROM tb1 LEFT OUTER JOIN tb2 ON
(tb1.id1=tb2.id1 AND tb1.id2=tb2.id2) 
 WHERE tb2.id1 IS NULL