实际上,它们都是赋值运算符,用于赋值,但它们之间的显着区别如下 -
= 运算符赋值为SET 语句的一部分或作为 UPDATE 语句中 SET 子句的一部分,在任何其他情况下 = 运算符都被解释为比较运算符。另一方面,:= 运算符分配一个值,并且永远不会将其解释为比较运算符。
mysql> Update estimated_cost1 SET Tender_value = '8570.000' where id = 2; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> Update estimated_cost1 SET Tender_value := '8575.000' where id = 2; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0