同表同结构,利用中间表数据的更新
现在又两张表,表结构完全相同,需要更新b中的年龄数据,条件是a.姓名=b.姓名
a:
姓名  年龄 性别
张三  33    男
李四  34    男
b:
姓名  年龄 性别
张三  30    男
李四  32    男
张雪  35    女
李雪  29    女
SQL:
Update b set b.年龄=(select a.年龄 from a where a.姓名=b.姓名)
where b.姓名=(select a.姓名 from a where a.姓名=b.姓名)
update t_base_inventory t  set t.MEASURE_DESC2 =
(select t2.MEASURE_DESC2
from t_base_in2 t2
where t.inventory_code = t2.inventory_code)
where t.inventory_code =
(select t2.MEASURE_DESC2
from t_base_in2 t2
where t.inventory_code = t2.inventory_code)
where t.inventory_code =
         (select t2.inventory_code
from t_base_in2 t2
where t.inventory_code = t2.inventory_code)
from t_base_in2 t2
where t.inventory_code = t2.inventory_code)
                    
                
                
            
        
浙公网安备 33010602011771号