Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google bigquery 在Bigquery中不存在_Google Bigquery - Fatal编程技术网

Google bigquery 在Bigquery中不存在

Google bigquery 在Bigquery中不存在,google-bigquery,Google Bigquery,我想实现类似于 select * from table1 where not exists (select 1 from table2 where table1.col1 = table2.col1 and table1.col2 = table2.col2) 我无法在BQ中实现这一点。 如果您能提供帮助,我们将不胜感激。请使用“不在”。根据我的评论: 在BigQuery中执行这种“关系减法”操作的一种方法如下: SELECT table1.* FROM t

我想实现类似于

select * from table1
where not exists (select 1 from table2 where
                  table1.col1 = table2.col1 and table1.col2 = table2.col2)
我无法在BQ中实现这一点。 如果您能提供帮助,我们将不胜感激。

请使用“不在”。根据我的评论:

在BigQuery中执行这种“关系减法”操作的一种方法如下:

SELECT table1.* FROM table1 LEFT OUTER JOIN table2 
  ON  table1.col1 = table2.col1 AND table1.col2 = table2.col2
WHERE table2.col1 IS NULL AND table2.col2 IS NULL

不同之处的可能重复之处在于,这里的半连接位于两列上,而在链接问题中,它位于一列上。我认为在这种情况下不可能使用IN谓词。原始问题中的示例在两列上使用了相关的EXISTS子查询,我不确定是否可以使用IN谓词建模。感谢您的评论Felipe,我尝试了您给出的解决方案,但这不适用于相关子查询。
SELECT table1.* FROM table1 LEFT OUTER JOIN table2 
  ON  table1.col1 = table2.col1 AND table1.col2 = table2.col2
WHERE table2.col1 IS NULL AND table2.col2 IS NULL