oracle upadate多表关联修改 求问在有重复值的情况下该怎么写

update X_YBYPJBBIAOZHUN a 
set ybypbianma=(select b.ybypguojiabianma  from X_YBYPduiying210508 b where b.ybypjiubianma=a.ybypid)
where exists (select 1
from X_YBYPduiying210508 b where b.ybypjiubianma=a.ybypid
);

ybypguojiabianma字段中有重复值。我想应该在问题在这。

 

针对你的问题,可以考虑使用DISTINCT关键字去除ybypguojiabianma字段中的重复值,修改后的SQL语句如下:

update X_YBYPJBBIAOZHUN a
set ybypbianma=(select DISTINCT b.ybypguojiabianma from X_YBYPduiying210508 b where b.ybypjiubianma=a.ybypid)
where exists (select 1
from X_YBYPduiying210508 b where b.ybypjiubianma=a.ybypid
);

这样可以解决ybypguojiabianma字段中的重复值的问题。