# UPDATE

Changes the values of the specified columns based on the `assign` argument (`identifier=expression`) in all rows that satisfy the condition in the `WHERE` clause.

```sql
UPDATE table_name SET assign [, assign ]* [ WHERE booleanExpression ]
```

#### Example

```
UPDATE UFOs SET shape='ovate' where shape='eggish';
```

{% hint style="info" %}
Currently, HEAVY.AI does not support updating a geo column type (POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, or MULTIPOLYGON) in a table.
{% endhint %}

## Update Via Subquery

You can update a table via subquery, which allows you to update based on calculations performed on another table.

**Examples**

{% tabs %}
{% tab title="Example 1" %}

```sql
UPDATE test_facts SET lookup_id = (SELECT SAMPLE(test_lookup.id) 
FROM test_lookup WHERE test_lookup.val = test_facts.val);
```

{% endtab %}

{% tab title="Example 2" %}

```sql
UPDATE test_facts SET val = val+1, lookup_id = (SELECT SAMPLE(test_lookup.id)
FROM test_lookup WHERE test_lookup.val = test_facts.val);
```

{% endtab %}

{% tab title="Example 3" %}

```sql
UPDATE test_facts SET lookup_id = (SELECT SAMPLE(test_lookup.id) 
FROM test_lookup WHERE test_lookup.val = test_facts.val) WHERE id < 10;
```

{% endtab %}
{% endtabs %}

## Cross-Database Queries

In Release 6.4 and higher, you can run UPDATE queries across tables in different databases on the same HEAVY.AI cluster without having to first connect to those databases.

To execute queries against another database, you must have ACCESS privilege on that database, as well as UPDATE privilege.

#### Example

Update a row in a table in the `my_other_db` database:

```sql
UPDATE my_other_db.customers SET name = 'Joe' WHERE id = 10;
```
