读书人

两个表之间的数据更新的sql解决办法

发布时间: 2012-03-15 11:50:38 作者: rapoo

两个表之间的数据更新的sql
表A:ID, PRICEA
0001 10
0002 20
表B:ID, PRICEB
0001
0002

我想要的结果是:

表B:ID, PRICEB
0001 10
0002 20

[解决办法]

SQL code
update b set priceb=a.pricea from 表A a inner join 表B b on a.id=b.id
[解决办法]
SQL code
update b set PRICEB=a.PRICEA from a join b on a.id=b.id
[解决办法]
update b set PRICEB=a.PRICEA from a , b where a.id=b.id
[解决办法]
SQL code
update b set priceb=a.pricea from 表A a inner join 表B b on a.id=b.id
[解决办法]
update b set PRICEB=a.PRICEA from a , b where a.id=b.id

读书人网 >SQL Server

热点推荐