读书人

多表联系关系的update语句

发布时间: 2012-07-19 16:02:20 作者: rapoo

多表关联的update语句

ORACLE?UPDATE?多表关联的update语句

??--?update?超过2个值
???update?customers?a???--?使用别名
???set????(city_name,customer_type)=(select?b.city_name,b.customer_type?
?????????????????????????????????????from???tmp_cust_city?b?
?????????????????????????????????????where??b.customer_id=a.customer_id)
???where??exists?(select?1?
??????????????????from???tmp_cust_city?b
??????????????????where??b.customer_id=a.customer_id
?????????????????)

?

-----------------------------------------

MSSql的多表关联的update语句?
例如A表 存在一下字段:
AID A1 A2 A3 A4

B表中存在字段:
BID B1 B2 B3 B4

如果实现用B表的所有字段更新A表中相应的字段,在MS SQL Server里面可以写成:
update A
set A1=B.B1,A2=B.B2,A3=B.B3,A4=B.B4
from A,B
where A.AID=B.BID

读书人网 >PowerDesigner

热点推荐