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
未经测试