说起来有点复杂。现在有两张表,a跟b,a.unid=b.a_unid
但是在a表中有字段c_field,如果c_field里存了一个a的unid,那么有该c_field的a的item就是个house item,c_field指向的item是master item
现在,要把master item对应的b table中的值cno,批量赋到house item对应的b table的cno中去
sql语言要怎么写啊?
但是在a表中有字段c_field,如果c_field里存了一个a的unid,那么有该c_field的a的item就是个house item,c_field指向的item是master item
现在,要把master item对应的b table中的值cno,批量赋到house item对应的b table的cno中去
sql语言要怎么写啊?
a1的值:house1,master1
a2的值:master1,nullb表也有对应的两个值,b表中字段的值a_unid,contractnob1的值:house1,null
b2的值:master1,100现在我想把b1的contractno的值变成b2的100
sql要怎么写呢
例如a1:house1, master2
a2:master2, master1
a3:master1, null
merge into b t1
using (select a.unid, b.contractno
from a, b
where a.lot_unid = b.a_unid) t2
on (t1.a_unid = t2.unid)
when matched then
update set t1.contractno = t2.contractno;