diff --git a/mysql-compatibility.md b/mysql-compatibility.md index 1a6fcb8ec2219..a9605404bc3b6 100644 --- a/mysql-compatibility.md +++ b/mysql-compatibility.md @@ -126,6 +126,10 @@ These differences are documented further in [`ANALYZE TABLE`](/sql-statements/sq For details, see the [`SELECT`](/sql-statements/sql-statement-select.md) statement reference. +### `UPDATE` statement + +See the [`UPDATE`](/sql-statements/sql-statement-update.md) statement reference. + ### Views Views in TiDB are not updatable. They do not support write operations such as `UPDATE`, `INSERT`, and `DELETE`. diff --git a/sql-statements/sql-statement-update.md b/sql-statements/sql-statement-update.md index a675cfe327305..88f019146a2e3 100644 --- a/sql-statements/sql-statement-update.md +++ b/sql-statements/sql-statement-update.md @@ -70,7 +70,17 @@ mysql> SELECT * FROM t1; ## MySQL compatibility -This statement is understood to be fully compatible with MySQL. Any compatibility differences should be [reported via an issue](https://github.com/pingcap/tidb/issues/new/choose) on GitHub. +TiDB always uses the original value of a column when evaluating expressions. For example: + +```sql +CREATE TABLE t (a int, b int); +INSERT INTO t VALUES (1,2); +UPDATE t SET a = a+1,b=a; +``` + +In MySQL, the column `b` is updated to 2 because it is set to the value of `a`, and the value of `a` (which is 1) is updated to `a+1` (which is 2) in the same statement. + +TiDB follows the more standard SQL behavior, and updates `b` to 1. ## See also