我有一张表 A
ul.a li {padding:7px;}
表 B
col-PK col2 col3 col4
1 a aa aaa
2 b bb bbb
当col2 = colB
时,我需要使用col-PK colB temp
1 a
2 b
填写temp
列
我的Attmept
col3
但它无法正常工作。我为Update B Set temp = (Select A.col3 from A join B where A.col2 = B.colB)
中的所有行获取了相同的值。
输出错误:
temp
答案 0 :(得分:2)
您可以使用加入
的uoadte Update B
JOIN A on A.col2 = B.colB
Set B.temp = A.col3
答案 1 :(得分:1)
UPDATE B Set temp = (SELECT col3 from A where A.col2 = B.colB)