[英]How to JOIN three tables in BigQuery by a common column name
我有三个具有以下关系的表。
t1 有 program_id
t2 有 program_id 和 product_name
t3 有 product_name 和 price
t1
order_id|product_id| program_id
1 | AA| 100
2 | BB| 110
3 | CC| 500
4 | DD| 550
t2
name |program_id| name
mike | 100| 1bx
john | 110| 2bx
bob | 500| 3bx
clara | 550| 3bx
jane | 112| 55x
t3
admin_id|product_name|revenue
z1 | 1bx| 100
z2 | 2bx| 110
z3 | 3bx| 500
z4 | 4bx| 550
我的目的是加入前两个表,然后将第一个 JOIN 的结果与第三个表连接起来。 最后它应该看起来像:
t4
program_id|product_name|revenue
z1 | 1bx| 100
z2 | 2bx| 110
z3 | 3bx| 500
z4 | 4bx| 550
其中 t3 会给我每个 program_id 和 product_name 的价格。 如何使用第一个 Join 的结果有效地加入第三个表?
这对我来说就像两个JOIN
:
select program_id, product_name, revenue as price
from table1 t1 join
table2 t2
using (program_id) join
table3 t3
using (product_name);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.