1.
declare
cursor t1 is select * from tablename;
begin
for rec in t1 loop
update tablename t set t.detail=rec.jieshao where t.objectid=rec.objid;
end loop;
end;
2.update student set (name,id )=
(select name ,id from (select student.rowid rd,student1.name,student1.id from student1,student where student1.int_id =student.int_id) tmp
where student.rowid=tmp.rd);
commit;
3.update test_a a set (a.name,a.age)=
(select b.name,b.age from test_b b where a.id = b.id) where exists
(select * from test_b c where c.id=a.id)
4.update t_a set djrq=
(
select djrq from t_b where t_a.id = t_b.id
where rownum = 1
)
where t_a.id in
(
select id from t_b where jwh='xx村'
) 5.
update tbl1 a
set (a.col1, a.col2) = (select b.col1, b.col2
from tbl2 b
where a.key = b.key)
where a.key in(select key from tbl2)
儲存過程 根據乙個表對另乙個表進行更新
編寫mysql儲存過程,通過查詢乙個表中資料,更新到另外乙個表中 舉例來說,存在兩張表roledata,scoreinfo,下面儲存過程,通過游標,遍歷查詢scoreinfo表中scroe的值來更新表roledata中的role scroe值 drop procedure if exists pro...
Oracle中用乙個表的資料更新另乙個表的資料
更新完後的結果是 select from tab1,在tab1中有的行,如果在tab2中沒有對應的行,值被更新為null.比如在tab2中再插入一條 insert into tab2 values 2,x merge into tab1 using select from tab2 x where ...
用乙個表去更新另乙個表
朋友今天問我乙個問題 有兩張資料表 bureau area code 和 county code,我想用town code擷取前6位去和county code擷取前6位查詢,查到對應的county name該咋寫?下面先是兩張表結構 1 create table bureau area code 2...