使用join语句在google big query中显示表别名的所有字段

时间:2017-09-22 13:43:21

标签: sql google-bigquery

我有一个简单的连接语句的查询,我想打印一个表的所有字段。

select t1.id, t1.field1, ..., t1.fieldN
from first_table as t1
join second_table as t2 on t1.id = t2.id
where t1.field1 = "some value"

我可以用某种方式构建(或存在一个快捷方式)带有*通配符的select语句吗?

select t1.*
from first_table as t1
join second_table as t2 on t1.id = t2.id
where t1.field1 = "some value"

1 个答案:

答案 0 :(得分:3)

当您使用BigQuery Legacy SQL加入时,如第二个查询中的帖子 - 您将输出前缀为表别名的输出字段为t1_id,t1_field1等等

请使用没有此行为的BigQuery Standard SQL

  

试试

#standardSQL
SELECT t1.*
FROM first_table AS t1
JOIN second_table AS t2 ON t1.id = t2.id
WHERE t1.field1 = "some value"