=8800084 andT1.col3 <=8852884" />
开发者

update table from another table in db2 9

开发者 https://www.devze.com 2023-02-04 08:05 出处:网络
hi i run this script \" UPDATEt1 SETT1.col1= T2.col1 FROMaaat1, bbbt2 WHERE T1.col2=138802 AND T1.col3 >=8800084 andT1.col3 <=8852884

hi i run this script " UPDATE t1 SET T1.col1= T2.col1 FROM aaa t1 , bbb t2 WHERE T1.col2=138802 AND T1.col3 >=8800084 and T1.col3 <=8852884 AND T1.col4=0 AND T1.col5=T2.col2" and i get syntax error !开发者_如何学运维!! (ILLEGAL USE OF KEYWORD FROM) how i can run this script???


Here's a modified version:

UPDATE aaa t1
  SET T1.col1 = (SELECT T2.col1 FROM bbb t2 WHERE T1.col5=T2.col2)
  WHERE T1.col2=138802 AND T1.col3 >=8800084 and T1.col3 <=8852884 AND T1.col4=0

I isolated the T2 stuff in a subquery with an explicit SELECT. Note that the subquery will run for every row that is updated.

0

精彩评论

暂无评论...
验证码 换一张
取 消