我有二个结构相同的表A,B, 它们有字段ID,data1,data2 ,现在我想把A表的data1赋值到B表的data1中,根据二者的ID如果相同的话,
为什么这样写不行哦update b
set b.data1 = (select data1 from a where a.id = b.id)
where exists(select 1 from A where a.id = b.id)为什么这样不行呢,请高手指点下,在线等待,谢谢了!其中ID是NCHAR类型
为什么这样写不行哦update b
set b.data1 = (select data1 from a where a.id = b.id)
where exists(select 1 from A where a.id = b.id)为什么这样不行呢,请高手指点下,在线等待,谢谢了!其中ID是NCHAR类型
set b.data1 = (select data1 from a where a.id = b.id)
from b
where exists(select 1 from A where a.id = b.id)
where trim(a.id) = trim(b.id) and rownum-1
set b.data1 = (select data1 from a where a.id = b.id)
where exists(select 1 from A where a.id = b.id)
这个方法好像是可以的,可能是我当时写错了,二楼 加了一个from b 反而报错,提示命令未能正确结束那请问大家,到底是否要加 from b ?
update b
set b.data1 = (select data1 from a where a.id = b.id)
where exists(select 1 from A where a.id = b.id)最后一句 where exists(select 1 from A where a.id = b.id) 有什么作用呢?去掉行吗?
using a
on(a.id=b.id)
when matched then update a.data1 =b.data1 ;
如果我加个条件 A.data1>0 的话,那是不是应该这样写
update b
set b.data1 = (select data1 from a where a.id = b.id)
where exists(select 1 from A where a.id = b.id and A.data1>0)还有 A,B表ID字段是NCHAR类型 ,写成a.id = b.id 是没问题的吧~