# 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;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.heavy.ai/sql/data-manipulation-dml/sql-capabilities/update.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
