join 해서 값 가지고온후 테이블에 update 하기

오라클 10g 이상에서 사용됨.

sal_tbl , user_tbl에서 각각의 값을 select후 user_tbl.dept_cd = sal_tbl.dept_nm를 업데이트

 

update /*+BYPASS_UJVC*/(
      SELECT a.id 

           ,a.name 

           ,a.dept_cd
            ,b.dept_nm 

            ,b.sal

    FROM sal_tbl b  , user_tbl a
    WHERE  B.id =  a.id
    and b.h_id in (
        select  b.id from user_tbl 

       where a.uid is not null

    )
)temp
set
temp.dept_cd =temp.dept_nm

 

 

 

+ Recent posts