2012年12月31日 星期一

mssql Update from another table / 更新資料使用別的TABLE

引用來源
--
  1. UPDATE TABLEA
  2. SET (b, c, d) = (SELECT b1, c1, d1 from TABLEB WHERE TABLEB.a1 = TABLEA.a and TABLEB.e1 > 40)
  3. WHERE EXISTS (SELECT 1 from TABLEB WHERE TABLEB.a1 = TABLEA.a and TABLEB.e1 > 40)
  4.  
  5. update (
  6. select a.fileld, b.fileld
  7. from TABLEA a, TABLE b
  8. where
  9. a.key = b.key 
) set fileld = fileld  

沒有留言:

張貼留言