现有数据表table1,table2,table1的列为id,name,table2的列为id,age。
两张表里都已有数据,现需要将table2里的age数据添加到table1,要怎么处理
注,已尝试过 添加一列后
update table1 a set a.age=(select b.age from table2 b where a.id=b.id)
运行后a.age 仍然为null
求解答,不胜感激
用update + inner join
update table1 a, table2 b
set a.age=b.age
where a.id = b.id