=
Operator Description
The = operator is used to assign values in the following cases:
-
In the
SETstatement,=is regarded as an assignment operator, that is, the user variable to the left of the operator=takes the value to its right. The value to the right can be a text value, another variable that stores the value, or any legal expression that produces a scalar value, or it can also include the result of the query (provided that the value is a scalar value). Multiple assignments can be performed in the sameSETstatement. -
In the
SETclause of theUPDATEstatement,=also acts as an assignment operator. You can make multiple assignments in the sameSETclause of aUPDATEstatement. -
In other cases,
=is used as the comparison operator.
Grammar Structure
> SELECT column1, column2, ...
FROM table_name
WHERE columnN = value1;
Example
create table t1 (a bigint(3), b bigint(5) primary key);
insert into t1 VALUES (1,1),(1,2);
update t1 set a=2 where a=1 limit 1;
mysql> select * from t1;
+------+------+
| a | b |
+------+------+
| 2 | 1 |
| 1 | 2 |
+------+------+
2 rows in set (0.00 sec)