目前使用比较多的数据库:MYSQL与ORACLE 而SQL SERVER 用的比较少,查询大致都差不多,但是更新与删除有些不一样(单表操作这里就不说了,也差不多)

SQL SERVER多表关联更新:
更新tab_1表code,当name为空并且存在tab_2中,更新为tab_2中code的值

update p set p.t1_code=r.t2_code from tab_1 p,tab_2 r where p.t1_id=r.t1_id and (p.t1_name is null or p.t1_name='');

删除与更新操作类似:

 delete p from tab_1 p,tab_2 r where p.t1_id=r.t1_id and (p.t1_name is null or p.t1_name='');

已验证。可行。

更多推荐

SQL SERVER 多表关联更新