Bug #70727 updating same row multiple times not working
Submitted: 25 Oct 2013 17:18 Modified: 6 Dec 2013 21:21
Reporter: Franjo Markovic Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:5.6.14 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[25 Oct 2013 17:18] Franjo Markovic
Description:
Script below results in a value "1" for aa1.tot column,
meaning that only first matched row affected the update,
other then all the rows.
Proper result value should be "6".

How to repeat:

create table aa1 (id int, tot int);
insert into aa1 (id, tot) values (1,0);

create table aa2 (id int, det int);
insert into aa2 (id, det) values (1,1),(1,2),(1,3);

update aa1 join aa2 using (id) set tot = tot + det;

select * from aa1;
[14 Nov 2013 19:24] Sveta Smirnova
Thank you for the report.

This is not a bug: table aa1 contains 1 row which is updated, using first corresponding row from the join result.

But I agree it can be confusing, therefore verify this report as documentation bug.
[6 Dec 2013 21:21] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Modifying the UPDATE section (e.g.,
http://dev.mysql.com/doc/refman/5.6/en/update.html) to say:

For the multiple-table syntax, UPDATE updates rows in each table
named in table_references that satisfy the conditions. Each matching
row is updated once, even if it matches the conditions multiple
times.