Mayank
Mayank

Reputation: 407

Google BigQuery-Joined Resultset from Multiple Table

Hello I am Importing Google Analytics CostData to Google BigQuery each day, table is created like Costdata_yyyymmdd for each day. I need a joined result in a Select query for all the dates table.

TableName

Costdata_20180401

Costdata_20180402

Costdata_20180403

Costdata_20180404

Costdata_20180405 ..... Costdata_yyyymmdd

Required Result:

select * from Costdata_20180401
union all 
select * from Costdata_20180402 
union all Costdata_yyyymmdd

What would be the best approach in Google BigQuery to achieve this ?

Upvotes: 0

Views: 107

Answers (1)

Martin Weitzmann
Martin Weitzmann

Reputation: 4746

You can use table wildcards for this https://cloud.google.com/bigquery/docs/reference/standard-sql/wildcard-table-reference

SELECT * 
FROM  ´Costdata_*´ 
WHERE _table_suffix 
  BETWEEN '20180401' AND '20180413'

Upvotes: 1

Related Questions