小妹我是初学者,遇到个小问体,请各位大哥帮帮忙,我有两张表table1和table2,我想根据tale1中的一个字段来截取一定的长度等于table2中的一个字段来更新table1,请问我下面这种写法对吗?
update table1
set
a=table2.a
,b=table2.b
,c=table2.c
from table2
where
d is null
and (substring(e,2,4) = table2.n
or substring(e,8,3)=table2.n )如果e的某条记录的substring(e,6,20)和substring(e,15,9)都在table2中找到匹配的数据了,那更新会不会有问题?
update table1
set
a=table2.a
,b=table2.b
,c=table2.c
from table2
where
d is null
and (substring(e,2,4) = table2.n
or substring(e,8,3)=table2.n )如果e的某条记录的substring(e,6,20)和substring(e,15,9)都在table2中找到匹配的数据了,那更新会不会有问题?
set
table1.a=table2.a ,
table1.b=table2.b ,
table1.c=table2.c
from table2
where table1.d is null
and (substring(table1.e,2,4) = table2.n
or substring(table1.e,8,3)=table2.n )
and table2.f= ??? // 给table2加点条件不知道可不可以??
set table1.a=table2.a,
table1.b=table2.b,
table1.c=table2.c
from table2
where table.d is null
and (substring(table1.e,2,4) = table2.n or substring(table1.e,8,3)=table2.n)----------------------------Oracle学习中-----------------------------
set
table1.a=table2.a
,table1.b=table2.b
,table1.c=table2.c
from table2
where
table1.d is null
and (substring(table1.e,2,4) = table2.n
) 你用or的话不会出现一对多的关系吗 如果不会就可以用
Oracle中的更新應該是下面的吧:
Update A
set (a,b,c)=(Select a,b,c From B Where A.a=B.a)
Where exists(Select 1 from B Where A.a=B.a)