怎样用sql语句,在oracle中将一个表中查出来的字段插入另外一个表中的相应字段

如题所述

兄弟,这是更新原有数据,而不是插入新数据,表述要准确,使用关联更新即可
update
sis
a
set
a.sid=(select
outid
from
b_cust
b
where
b.idcardno=a.cardno
where
rownum=1)
where
exists
(select
1
from
b_cust
c
where
c.idcardno=a.cardno)
温馨提示:内容为网友见解,仅供参考
第1个回答  2019-10-01
LZ的意思是查出b_cust表中的b_cust.idcardno=sis.cardno的所有记录中的outid插入到sis表中对应的sid列吧
用游标来做试试:
create
or
replace
procedure
pro_test
as
cursor
cur_test
is
select
outid,idcardno
from
b_cust,sis
where
idcardno=cardno;
begin
for
I
in
cur_test
loop
update
sis
set
sid=I.outid
where
cardno=I.idcardno;
end
loop;
end;
/
exec
pro_test;
楼下的哥们我知道这是update操作,确实是我表述不清楚了。。。汗。。
相似回答
大家正在搜