At that point you can do a number of things. You can delete the extra rows (maybe there aren't that many and you don't want them anyway) and update as in your original query, or you can use aggregation in the subquery you're using to update, e.g.:update db1.CENSUS set (notes)=( select MAX(notes) from db2.CENSUS cen where db1.CENSUS.uid = cen.uid)where headcount_ind = 'Y' and capture_FY = '2015';此外,按照上面的方式进行查询,如果对于db1.CENSUS.uid的某些值,如果db2.CENSUS中没有对应的notes值,则db1.CENSUS.notes将设置为NULL.也许这就是您想要的行为?如果没有,您将需要以下内容:In addition, with your query the way it is above, if there is not a corresponding value of notes in db2.CENSUS for some value of db1.CENSUS.uid, db1.CENSUS.notes will be set to NULL. Maybe that's the behavior you want? If not, you'll want something like the following:UPDATE db1.census c1 SET c1.notes = ( SELECT max(c2.notes) FROM db2.census c2 WHERE c2.uid = c1.uid ) WHERE c1.headcount_ind = 'Y' AND c1.capture_FY = '2015' AND EXISTS ( SELECT 1 FROM db2.census c2 WHERE c2.uid = c1.uid ); 这篇关于如何解决ORA-01427错误(单行子查询返回多个行)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-12 18:34