如何通过从另一个表获取值来更新一个表的所有记录? [英] how to update all records of one table by taking value from another table ?
问题描述
如何通过从另一个表获取值来更新一个表的所有记录?
我在表1中存储了一些错误的数据
(FK表1.B栏-表2.A栏)
表1
A栏B栏B栏
1 3 222(预期为555)
2 4223(预计666)
3 5 224(预计777)
表2
A列B列
3 555
4666
5 777
而我的要求是
表1
A栏B栏B栏
1 3 555
2 4 666
3 5 777
我应该如何编写Sql Update查询?
how to update all records of one table by taking value from another table ?
I have stored some wrong data in table 1
( FK Table1.Column B - Table2.Column A )
Table 1
Column A Column B Column B
1 3 222(Expected 555)
2 4 223(Expected 666)
3 5 224(Expected 777)
Table 2
Column A Column B
3 555
4 666
5 777
and My Requirement is
Table 1
Column A Column B Column B
1 3 555
2 4 666
3 5 777
How should I write the Sql Update Query ?
推荐答案
请参见以下链接中的示例#2:
http://techonthenet.com/sql/update.php [
See example #2 in the following link :
http://techonthenet.com/sql/update.php[^]
Cheers
这篇关于如何通过从另一个表获取值来更新一个表的所有记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!