×
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.
Typically (but not always), your joined update statement will look something
like this:
UPDATE myFile A
SET fieldToUpdate =
(SELECT B.newData
FROM myOtherFile B
WHERE a.ID = b.ID ....)
WHERE EXISTS
(SELECT B.newData
FROM myOtherFile B
WHERE a.ID = b.ID ....)
If the additional "etc." selection criteria you mentioned is on myFile
alone, then you can put it in the UPDATE's WHERE clause only.
Note that the join has to be performed with the implicit-join syntax (in the
WHERE clause of the subselect), rather than the explicit-join syntax (not
supported for UPDATEs and DELETEs).
Some rudimentary gotcha's of joined updates are covered in the "Anatomy of a
joined UPDATE" article on
page 9 of this Centerfield newsletter:
http://www.centerfieldtechnology.com/publications/archive%5CDecember%202006.
pdf
Many other authors have written on this topic, and the archive has number of
examples as well.
HTH, Elvis
Celebrating 11-Years of SQL Performance Excellence on IBM i, i5/OS and
OS/400
www.centerfieldtechnology.com
-----Original Message-----
Subject: SQL update question
To avoid errors when updating I usually do this :
Select fieldToUpdate from myfile where etc..
Then this :
Update myfile set fieldToUpdate = 'new data' where etc..
But now I have to join 2 files :
Select fieldToUpdate from myfile a join myOtherfile b on a.ID = b.ID where
etc..
How do I do the update now?
Thanks
As an Amazon Associate we earn from qualifying purchases.