\=

Description

This = operator is used to perform value assignments in the below cases:

  • Within a SET statement, = is treated as an assignment operator that causes the user variable on the left hand side of the operator to take on the value to its right. The value on the right hand side may be a literal value, another variable storing a value, or any legal expression that yields a scalar value, including the result of a query (provided that this value is a scalar value). You can perform multiple assignments in the same SET statement.

  • In the SET clause of an UPDATE statement, = also acts as an assignment operator. You can make multiple assignments in the same SET clause of an UPDATE statement.

  • In any other context, = is treated as a comparison operator.

Syntax

  1. > SELECT column1, column2, ...
  2. FROM table_name
  3. WHERE columnN = value1;

Examples

  1. create table t1 (a bigint(3), b bigint(5) primary key);
  2. insert into t1 VALUES (1,1),(1,2);
  3. update t1 set a=2 where a=1 limit 1;
  4. mysql> select * from t1;
  5. +------+------+
  6. | a | b |
  7. +------+------+
  8. | 2 | 1 |
  9. | 1 | 2 |
  10. +------+------+
  11. 2 rows in set (0.00 sec)