Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bigquery how to query multiple tables of the same structure?

I have datasets of the same structure and i know I can query them like this, they are named by date:

SELECT column
FROM [xx.ga_sessions_20141019] ,[xx.ga_sessions_20141020],[xx.ga_sessions_20141021] 
WHERE column = 'condition';

However I actually want to query various months of this data... so instead of listing them all in the same way as above, is there syntax that you can use that looks like:

SELECT column
FROM [xx.ga_sessions_201410*] ,[xx.ga_sessions_201411*]
WHERE column = 'condition';
like image 571
shecode Avatar asked Mar 18 '23 20:03

shecode


1 Answers

Take a look at the table wildcard functions section of the BigQuery query reference. TABLE_DATE_RANGE or TABLE_QUERY will work for you here. Something like:

SELECT column
FROM TABLE_DATE_RANGE(xx.ga_sessions_,
                      TIMESTAMP('2014-10-19'),
                      TIMESTAMP('2014-10-21'))
WHERE column = 'condition';
like image 130
Danny Kitt Avatar answered Apr 29 '23 07:04

Danny Kitt