UPDATE

Updates the data in the table. After the SET keyword, enter the columns where you want to update values and the new values themselves. The list of rows is defined by the WHERE clause. If WHERE is omitted, the updates are applied to all the rows of the table.

UPDATE can’t change the value of PRIMARY_KEY.

Note

The table state changes can’t be tracked within a single transaction. If the table has already been changed, use UPDATE ON to update the data within the same transaction.

Example

  1. UPDATE my_table
  2. SET Value1 = YQL::ToString(Value2 + 1), Value2 = Value2 - 1
  3. WHERE Key1 > 1;

UPDATE - 图1

UPDATE ON

Used to update the data within a same transaction, if the table has already been changed.

Example

  1. $to_update = (
  2. SELECT Key, SubKey, "Updated" AS Value FROM my_table
  3. WHERE Key = 1
  4. );
  5. SELECT * FROM my_table;
  6. UPDATE my_table ON
  7. SELECT * FROM $to_update;

UPDATE - 图2