INNER JOIN in UPDATE sql for DB2 -
is there way use joins in update statements db2?
google has let me down on one
this i'm trying achieve (... except working ....)
update file1 inner join file2 on substr(file1.firstfield,10,20) = substr(file2.anotherfield,1,10) set file1.firstfield = ( 'bit of text' concat file2.something ) file1.firstfield 'blah%'
cheers
you don't platform you're targeting. referring tables files, though, leads me believe you're not running db2 on linux, unix or windows (luw).
however, if are on db2 luw, see merge statement:
for example statement, written as:
merge file1 using (select anotherfield, file2) b on substr(a.firstfield,10,20) = substr(b.anotherfield,1,10) when matched , a.firstfield 'blah%' update set a.firstfield = 'bit of text' || b.something;
please note: db2, third argument of substr function number of bytes return, not ending position. therefore, substr(a.firstfield,10,20) returns char(20). however, substr(b.anotherfield,1,10) returns char(10). i'm not sure if done on purpose, may affect comparison.
Comments
Post a Comment