Omdat MySQL geen multi-row indepent updates ondersteund, gebruik ik een work around met een update table.
Het gaat om de laatste query. Na deze query verwacht ik in t (1, 2) en (2, 0), maar ik zie (1, 1) en (2, 0).
Weet iemand waardoor dit komt?
Het gaat om de laatste query. Na deze query verwacht ik in t (1, 2) en (2, 0), maar ik zie (1, 1) en (2, 0).
Weet iemand waardoor dit komt?
SQL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| DROP TABLE t; DROP TABLE tu; CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0' ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO t VALUES (1, 0); INSERT INTO t VALUES (2, 0); CREATE TABLE tu ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0' ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO tu VALUES (1, 1); INSERT INTO tu VALUES (1, 1); UPDATE t INNER JOIN tu USING (a) SET t.b = t.b + tu.b; |