不同项目中表之间的 BigQuery JOIN

BigQuery JOINs between tables in different projects

我在两个不同的项目中有数据集。

我想将第一个项目中数据集中的 table 连接到第二个项目中数据集中的 table。

您能否提供此类查询的示例?

是的,你当然可以。您需要使用项目名称限定 table 名称,即 projectname:dataset.table 这是我在公共数据项目中加入我的 table 反对 table 的一个例子:

select sum(a.is_male)
from
(select is_male, year from [publicdata:samples.natality]) a
inner join
(select year from [moshap.my_years]) b
on a.year = b.year

更新:以上语法适用于旧版 SQL,标准 SQL 变为 projectname.dataset.table,即

select sum(a.is_male)
from
(select is_male, year from publicdata.samples.natality) a
inner join
(select year from moshap.my_years) b
on a.year = b.year