gbcr.net
当前位置:首页 >> upDAtE A sEt From >>

upDAtE A sEt From

update A set name = '小张' where age

不知道你这是什么数据库 Sql server: update a set a.c3=b.c3 from ( select b.c1 + b.c2 as bb , c3 from b ) as b , a where b.bb = a.c1 + a.c2 Oracle update a set a.c3=b.c3 where a.c1||a.c2 in (select a.c1||a.c2 from a,b where a.c1...

update a set Name=b.Name from b join a on (a.id = b.id)你试一下这个

update a set a.name=b.name from a,b where a.ID=b.ID 不是主键也无所谓的,进行多次更新而已

这样肯定不行的!得换用其它的方式! update table1,table2 set table1.A=table2.A where table1.B=table2.B

想办法保证赋值唯一就行了,否则聚合函数不能做UPDATE更新 如果select b.id from B b group by b.name中每一个b.name只有唯一一个b.id那么就可以 update A a set a.id = (select DISTINCT b.id from B b where a.name=b.name) 试试

什么数据库?不同数据库的语法不同

update table t1 set (t1.b, t1.c) = (select t2.b1, t2.c1 from table1 t2 where t1.a = t2.a1) where exists (select 1 from from table1 t2 where t1.a = t2.a1)

例如更新表@A的第二条变成表@B的id=6的数据 update @A set c1=b.c1 ,c2=b.c2,c3=b.c3 from @A a,@B b where a.id=2 and b.id=6

update A set qty=B.qty from A,B where A.id=B.id

网站首页 | 网站地图
All rights reserved Powered by www.gbcr.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com