× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thank you Elvis, for the script and the explanation for the subselect clause.

John McKee

Quoting Elvis Budimlic <ebudimlic@xxxxxxxxxxxxxxxxxxxxxxxxx>:

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
desired.

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
I've demonstrated.

Elvis

RPG & DB2 Summit | Minneapolis | October 1-4
Mike Cain - DB2 for i5/OS Temporary Indexes - The Good, The Bad, The Ugly
October 16
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

-----Original Message-----
Subject: RE: SQL question

Assumptions are correct.

Why is the subselect required? Is that how the second table is
associated with
the alias ('a' in this case)?

John McKee


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.






As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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 [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.