Sduty/MS-SQL

Update ~ from 사용하기

돌멘 2017. 11. 15. 17:36


1. Update시 조건을 걸어 update 시키기


   update table_name set column_name = 값참조table의 column_name

     from 값참조할 table

   where 대상table_name = 값참조할table_name

   

  ex)

   update aaa set item= xx.item

     from (select a.po, a.pon, a.item1, a.item

              from tm_po a

              left join tb b on  a.pon = b.pon

             where a.pon is not null) xx

   where aaa.po = xx.po

      and aaa.item is null