Question extracted from mysql update multiple columns with same now()
Second question why this query doesn't update the columns:
mysql> update table set last_update=last_monitor=now() where id=1; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0
Created a fiddle to illustrate the confusion.
create table t1 (
c1 INT NOT NULL,
c2 INT NOT NULL
);
insert into t1 values (0,0);
update t1 set c1=c2=1;
select * from t1;
| c1 | c2 |
|----|----|
| 0 | 0 |
I am expecting c1
and c2
to be set to 1
or the query to fail due to syntax error.
Actual result is that the query is succeeding without updating the columns, so c1
or c2
remain at initial value of 0
As the current behavior does not makes sense to me, I'm definitely missing something. Can someone share some light on how this expression gets evaluated by MySQL engine (or any other SQL engine) ?