a表有4个列,假如4列数据如下
a b c d
a d v d
a f d d
a h f e
d f g g
ds d d db表也有4个列,数据如下
a 1 c d
a 2 v d
a 3 d d
现在要把a表的第二列数据update成为b第二列的值
如何通过sql来实现,请赐教
a b c d
a d v d
a f d d
a h f e
d f g g
ds d d db表也有4个列,数据如下
a 1 c d
a 2 v d
a 3 d d
现在要把a表的第二列数据update成为b第二列的值
如何通过sql来实现,请赐教
a 2 v d
a 3 d d
a 1 f e
d 2 g g
ds 3 d d这样么?
是把
a 1 c d
a 2 v d
a 3 d d这3行的数据跟新到A表里,不存在的不跟新
set t1.col2 = (select t2.col2 from t2 where t1.col1 = t2.col1 and t1.col3 = t2.col3 and t1.col4 = t2.col4)
where exists (select 1 from t2 where t1.col1 = t2.col1 and t1.col3 = t2.col3 and t1.col4 = t2.col4)