Recently in MySQL Category

If you use MySQL, note this:


mysql> create database test;
Query OK, 1 row affected (0.01 sec)

mysql> use test;
Database changed
mysql> create table foo (
-> x int,
-> y int
-> );
Query OK, 0 rows affected (0.00 sec)

mysql> insert into foo values (1, 2);
Query OK, 1 row affected (0.00 sec)

mysql> select * from foo;
+------+------+
| x | y |
+------+------+
| 1 | 2 |
+------+------+
1 row in set (0.00 sec)

mysql> update foo set x=5,y=10,x=x+y;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from foo;
+------+------+
| x | y |
+------+------+
| 15 | 10 |
+------+------+
1 row in set (0.00 sec)

mysql>

I bolded the part that bothers me. No warnings. Double-updating the same value in the same row in the same statement throws no warnings (never mind errors!). I haven't checked the ANSI standard to see if this is mentioned, but it sure is worth noting.

September 2010

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Creative Commons License
This weblog is licensed under a Creative Commons License.