两张数据表如何更新?
有两张表:
表1
id  name  age
1   张三  23
3   李四  98
6   王五  78
8   麻子  32
表2
id  name  age birthday
1   张三  23   一月
3   李四       二月
6   王五       四月
8   麻子  32   八月
我想把表2的age 字段为空的数值,根据表1来填补完整即得出下表效果:
1   张三  23   一月
3   李四  98    二月
6   王五  78    四月
8   麻子  32   八月
------解决方案--------------------
SQL code
update t2 set age=isnull(t2.age,t1.age) from t1 where t2.id=t1.id;