DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 15th, 2007, 10:05 AM
btharris btharris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 2 btharris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 47 sec
Reputation Power: 0
Update Statement with an inner join

I have data that I've imported into a table in the AS/400 (DB2) from SQL 2000. I need to update a column in a table that previously existed on the AS/400 with the new data I've imported from SQL 2000.

Any idea how to do an update that contains an inner join in DB2?

Here is the problem:

Table1.Column2 (FFIITMAP. FFIHGTH) all records are blank
and I need to update them with the values from Table2.Column2 (cubiscan.CFFIHGTH)
where Table1.Column1(FFIITMAP.FFIITMN) = Table2.Column1(cubiscan.CFFIITMN)

This is how I would do it within SQL 2000
--DB2 Doesn't like the From:Keyword FROM not expected. Valid tokens: <END-OF-STATEMENT>.

Update idsdemo.FFIITMAP
set FFIHGTH = CFFIHGTH
From idsdemo.FFIITMAP
inner join idsdemo.cubiscan on ltrim(rtrim(idsdemo.cubiscan.CFFIITMN)) = ltrim(rtrim(idsdemo.FFIITMAP.FFIITMN))

And these two are ways the internet suggested but still won’t work:

--DB2 Says invalid Tokens
Update idsdemo.FFIITMAP
inner join idsdemo.cubiscan on ltrim(rtrim(idsdemo.cubiscan.CFFIITMN)) = ltrim(rtrim(idsdemo.FFIITMAP.FFIITMN))
set FFIHGTH = CFFIHGTH

--DB2 Says it returns more than one row
Update idsdemo.FFIITMAP
set FFIHGTH =
(select CFFIHGTH from idsdemo.cubiscan
inner join idsdemo.FFIITMAP on ltrim(rtrim(idsdemo.FFIITMAP.FFIITMN)) = ltrim(rtrim(idsdemo.cubiscan.CFFIITMN))
)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > Update Statement with an inner join


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway