SQL
Update from Other Table
A table can be updated based upon values from another table. This can be done by specifying a table in a `FROM` clause, or using a sub-select statement. Both approaches have the benefit of completing the `UPDATE` operation in bulk for increased performance.  
```sql
CREATE OR REPLACE TABLE original AS
SELECT 1 AS key, 'original value' AS value
UNION ALL
SELECT 2 AS key, 'original value 2' AS value;

CREATE OR REPLACE TABLE new AS
SELECT 1 AS key, 'new value' AS value
UNION ALL
SELECT 2 AS key, 'new value 2' AS value;

SELECT *
FROM original;
```  
<div class="narrow_table"></div>  
| key |      value       |
|-----|------------------|
| 1   | original value   |
| 2   | original value 2 |  
```sql
UPDATE original
SET value = new.value
FROM new
WHERE original.key = new.key;
```  
Or:  
```sql
UPDATE original
SET value = (
SELECT
new.value
FROM new
WHERE original.key = new.key
);
```  
```sql
SELECT *
FROM original;
```  
<div class="narrow_table"></div>  
| key |    value    |
|-----|-------------|
| 1   | new value   |
| 2   | new value 2 |