メモ28 mssqlのupdate:from構文

2526 ワード

原文:
メモ28 mssqlのupdate:from構文

メモ28 mssqlのupdate:from構文

 1 --mssql update :from 

 2 --a  b    id ,name , id,memo

 3 

 4 

 5 --b memo a    ID , 

 6 

 7 

 8 update b

 9 set memo = a.name

10 from a,b

11 where a.id = b.id  

12 -- from b , sql:

13 update b set memo=(select max(a.name) from a where a.id=b.id)

14 where exists(select 1   from a where a.id=b.id);

15 --  name id ,id 。