Febian Shah
Febian Shah

Reputation: 1007

BigQuery - Add fixed value to a column?

Is there a way to add a fixed value to a result/table/column?

I have two tables:

Table1 with Column1, Column2, Column3.

Table2 with ColumnA, ColumnB

I want to append Table2 to Table1.

Is there a way to do this?

Also, is there a way to append Table2 to Table1 AND set Column3 values for those rows to "ABC"?

Thanks!

Upvotes: 1

Views: 12730

Answers (1)

Jordan Tigani
Jordan Tigani

Reputation: 26617

You can do this with a query that has the 'allowLargeResults' flag set.

SELECT ColumnA as Column1, ColumnB as Column2, "ABC" as Column3 
     FROM Table2

You can then set the destination table to Table1 and set the writeDisposition to WRITE_APPEND. If you are using the UI, you can set these options via the 'enable options' button. Select table1 as the destination table, check 'allow large results' and select 'Append to table' as the Write Preference.

Upvotes: 3

Related Questions