日期:2014-05-17  浏览次数:21358 次

oracle自连接更新表内数据
有如下表t1 
subject doublesn  
gsy 001ok!  
gsy null  
tianjin 003ok!  
tianjin null  
hexi 005ok!  
hexi null  
zhenming null  

更新doublesn字段 让subject相同的列具有相同的doublesn值,更新以后应该如下 

subject doublesn  
gsy 001ok!  
gsy 001ok!  
tianjin 003ok!  
tianjin 003ok!  
hexi 005ok!  
hexi 005ok!  
zhenming null


------解决方案--------------------
update t1 set t1.doublesn = (select doublesn from t1 t2 where t1.subject = t2.subject and t2.doublesn is not null) where doublesn is null
 

未经测试