两张表:
A:id,age,column1,column2
B:id,age,column1,column2
A.id 与 B.id关联。
将B中age>40的column1,column2更新到A的相应记录中,只能写一个语句。
写出mysql和oracle两个版本。
2.oracle && mysql :
SQL2000:
A:id,age,column1,column2
B:id,age,column1,column2
A.id 与 B.id关联。
将B中age>40的column1,column2更新到A的相应记录中,只能写一个语句。
写出mysql和oracle两个版本。
update A
set A.column1 = (
select b.column1
from B where B.id = A.id
and B.age > 40
),
A.column2 = (
select b.column2
from B where B.id = A.id
and B.age > 40
)
2.oracle && mysql :
update A set (c1,c2)=(select c1,c2 from B where id=a.id and age>40)
where id in (select id from b where age>40)
SQL2000:
update a set column1=b.column1 ,column2=b.column2 from a ,b where a.id = b.id and b.age>40