更新多个字段的UPDATE语句

更新多个字段的UPDATE语句

                

                update tableA a
                   set (a.v1, a.v2, a.v3, a.v4) =   --使用括号确定更新的字段范围
                       (select c.value1, c.value2, c.value3, c.value4
                          from tableC c, tableD d
                         where d.id = c.id
                           and c.field = '0'
                           and a.test = d.test)  --被更新表字段与更新表字段进行关联
                 where exists (select 1  --使用exists确定其更新的数据记录范围
                          from tableB b
                         where a.id = b.id
                           and b.name = 'name')

猜你喜欢

转载自crabdave.iteye.com/blog/2220894