First subselect performs a join and picks the rows whose columns are going
to be used in the update.
Second subselect uses the existence clause to ensure that only matching rows
are updated, with non-matching rows left untouched.
Two subselects MUST have identical WHERE clauses for the UPDATE to work as
As a side note, this UPDATE could look "prettier" in MS-SQL syntax as it
allows familiar JOIN syntax to be used in UPDATE clauses. However, that
does not comply with SQL standards and System i does not permit for it (nor
do any other DB2 flavors). Instead, joins are done within the subselect as
RPG & DB2 Summit | Minneapolis | October 1-4
Mike Cain - DB2 for i5/OS Temporary Indexes - The Good, The Bad, The Ugly
2007 System i Fall Technical Conference | Orlando | November 4-7
Celebrating 10-Years of SQL Performance Excellence on IBM System i, eServer
iSeries and the server affectionately known as the AS/400
This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact