Hi,

Today I was surprised by MySQL... :)
I have a table like

create table MyTable (a int default 0 not null, b date);
insert into MyTable (a, b) values (1, null), (1, null), (1, null);

And today morning I executed update query:

update MyTable set a = 0 and b = now() where a = 1;

After that I have found that MySQL updated only first field 'a' and didn't
update second one 'b'.
It was a big surprise for me. 8-\

First thought was "It is a bug in MySQL".
But later I have found that the reason is a misprint that I made in 'update'
query.
Of course the query should be

update MyTable set a = 0,  b = now() where a = 1;

So MySQL understood "0 and b = now()" as expression
and after calculation

0 and b = now() => 0 and 0 => 0.

the query is:

update MyTable set a = 0 where a = 1;

Best regards,
Mikhail.



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to