How to update DB2 table with a join?

后端 未结 3 940
野的像风
野的像风 2021-01-16 13:59

I have two tables and I want to update by joining them. I am using DB2 V9.7.

ORDER_APPROVALS

ORDER_ID    CREATED_BY_ID   CREATED_BY         


        
3条回答
  •  生来不讨喜
    2021-01-16 14:54

    update ORDER_ATTRIBUTE OT set OT.VALUE = 
    (select CREATED_BY_NAME from ORDER_APPROVALS OA 
    where OA.ORDER_ID = OT.ORDER_ID and OA.PROCESS_DT is NULL) 
    where OT.ATTRIBUTE_ID = 123 
    

    With this it's enough.

提交回复
热议问题