我们可以在BigQuery中的两个不同项目中对表执行连接吗?

时间:2021-08-30 18:04:49

I have two projects having datasets. I want to perform join of one table from first project to table in second project. How can I do that? Query ?

我有两个有数据集的项目。我想在第二个项目中执行从第一个项目到表格的一个表的连接。我怎样才能做到这一点?查询?

1 个解决方案

#1


14  

Yes, you certainly can. You need to qualify the table name with project name, i.e. projectname:dataset.table Here is an example of my joining one of my tables against table in publicdata project:

是的,你当然可以。您需要使用项目名称限定表名,即projectname:dataset.table以下是我在publicdata项目中对表中的一个表加入的示例:

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

Update: The syntax above is for Legacy SQL, with Standard SQL it becomes projectname.dataset.table, i.e.

更新:上面的语法适用于旧版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

#1


14  

Yes, you certainly can. You need to qualify the table name with project name, i.e. projectname:dataset.table Here is an example of my joining one of my tables against table in publicdata project:

是的,你当然可以。您需要使用项目名称限定表名,即projectname:dataset.table以下是我在publicdata项目中对表中的一个表加入的示例:

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

Update: The syntax above is for Legacy SQL, with Standard SQL it becomes projectname.dataset.table, i.e.

更新:上面的语法适用于旧版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