表test1(f1,f2) test2(f1,f2)
test1
f1 f2
a
b
ctest2
f1 f2
1 a
2 a
3 b
4 c
5 c现在想更新test2中的f1字段值到test1中f1字段
当test1.f2=test2.f2时
但是 当test1.f2='a'时,对应test2中多条记录,此时不更新
最后结果:
test1
f1 f2
a
3 b
c
请问怎么写????
test1
f1 f2
a
b
ctest2
f1 f2
1 a
2 a
3 b
4 c
5 c现在想更新test2中的f1字段值到test1中f1字段
当test1.f2=test2.f2时
但是 当test1.f2='a'时,对应test2中多条记录,此时不更新
最后结果:
test1
f1 f2
a
3 b
c
请问怎么写????
set a.f1= b.f1
from test1 a ,test2 b
where a.f2 in (select f2 from test2 group by f2 having count(*)=1) and a.f2=b.f2
update a
set a.f1= b.f1
from test1 a ,test2 b
where a.f2 in (select f2 from test2 group by f2 having count(*)=1) and a.f2=b.f2谢谢
from Test1 a
inner join Test2 b on A.f2=B.f2
where A.f2 in (select f2 from Test2 group by f2 having count(*)=1)
where f2 in (select f2 from test2 group by f2 having count(*)=1)
set test1.f1=test2.f1
from test1,test2 where test2.f2 (select test1.f2 from test1) and test1.f2=teste1.f2