Home > Software design >  BIGQUERY: Select and replace
BIGQUERY: Select and replace

Time:08-26

I'm very new to bigquery and I am looking to run a query which selects every row from a table where touch_by_bot is false. I then want to replace these same row values with true.

I figured out how to pull the rows that are false but I can't figure out how to replace the false values with true:

'SELECT * FROM ... WHERE touched_by_bot = false'

CodePudding user response:

select * replace(true as touched_by_bot) from ... where touched_by_bot = false

or updating the table itself.

create temp table your_table as 
select false as touched_by_bot union all
select true;

update your_table set touched_by_bot = true where touched_by_bot = false;

select * from your_table;
  • Related