在 Big Query 中查询多个表 [英] Querying multiple tables in Big Query

查看:57
本文介绍了在 Big Query 中查询多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于无法在 BigQuery 中更新表内的数据,并且仅支持追加机制,因此我决定按月创建新表.所以假设 2012 年的表是 (tbl_012012, tbl_022012, tbl_032012,...tbl_122012).每条记录将与日期 timestamp 一起存储为字符串.

As it is not possible to update data within a table in BigQuery, and supports only append mechanism, I have decided to create new tables on monthly basis. So suppose for year 2012 the tables would be (tbl_012012, tbl_022012, tbl_032012,...tbl_122012). Each record will be stored along with date timestamp as string.

现在,如果我的应用程序想要获取从 2012 年 1 月(tbl_012012) 到 2012 年 3 月(tbl_032012) 的记录,BigQuery API 是否会通过以下方式自动遍历所需的表单个 SQL 范围查询还是我必须使用额外的应用程序代码编写多个 SQL 查询来检索每个查询结果,然后将它们聚合在一起?

Now, if my application wants to fetch records ranging from Jan 2012(tbl_012012) to March 2012(tbl_032012), will BigQuery API automatically traverse through the desired tables via single SQL range query or will I have to write multiple SQL queries with extra application code to retrieve each query result and then aggregate them altogether?

推荐答案

一个 SQL 查询可以引用多个表.只需在 FROM 子句中用逗号分隔每个表即可查询所有提到的表.

One SQL query can reference multiple tables. Just separate each table with a comma in the FROM clause to query across all mentioned tables.

这篇关于在 Big Query 中查询多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆