I want to update a value in array with a value in another table.
table1:
| event_params.key | event_params.value.string_value |
|---|---|
| country | US |
table2:
| country | new_country |
|---|---|
| US | NL |
I try
UPDATE table1
SET event_params = ARRAY(SELECT AS STRUCT * REPLACE ( new_country AS value.string_value ) FROM UNNEST(event_params)
WHERE key = "country")
FROM(SELECT country, new_country FROM table2)
WHERE
(SELECT value.string_value from unnest(event_params) where key = 'country') = t2.country
It doesnt work.. The problem is the value.string_value because is also an array.
The final table should look like table1:
| event_params.key | event_params.value.string_value |
|---|---|
| country | NL |
Now I want to update table1 with table2 to udate the country from US to NL in table1.
How can I take the array in array?