UPDATE bbb x SET x.id = (SELECT y.id FROM aaa y WHERE x.a = y.a AND x.b = y.b) WHERE EXISTS (SELECT 1 FROM aaa y WHERE x.a = y.a AND x.b = y.b);
update aaa a set a.ID=b.ID from (select * from bbb b where (select count(*) from bbb where a.A = A and a.B =B)=1) b where and a.A = A and a.B =B 但是提示:SQL命令未正确结束
update bbb set (col1,col2,col3...)=(select col1,col2,col3... from aaa where a=bbb.a and b=bbb.b) where exists(select 1 from aaa where a=bbb.a and b=bbb.b)
oracle好像没有update...from语句
update testb set id=(select a1.id from testa a1, testb b1 where a1.a=b1.a and a1.b=b1.b);
这种需求可以用merege来写啊: MERGE INTO aaa USING (SELECT * FROM bbb WHERE aaa.a = bbb.a) c ON aaa.b = c.b WHEN MATCHED THEN UPDATE SET id = c.id;
WHERE EXISTS (SELECT 1 FROM aaa y WHERE x.a = y.a AND x.b = y.b);
set a.ID=b.ID from
(select *
from bbb b
where (select count(*)
from bbb
where a.A = A
and a.B =B)=1) b
where
and a.A = A
and a.B =B
但是提示:SQL命令未正确结束
where a=bbb.a and b=bbb.b)
where exists(select 1 from aaa where a=bbb.a and b=bbb.b)
oracle好像没有update...from语句
MERGE INTO aaa
USING (SELECT * FROM bbb WHERE aaa.a = bbb.a) c
ON aaa.b = c.b
WHEN MATCHED THEN
UPDATE SET id = c.id;