Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ORA-01427: single-row subquery returns more than one row

CatinredbootsOct 16 2016 — edited Oct 18 2016

Hello,

I just want to say that I searched a LOT about this error on the wed and the only solution that I found is that my query needs to return only one record for it to work.

Basically, I need to update 3 fields in one table from another table where emails match on both tables and IDs are different.

Example:

update table_1 a

set (a.id, a.name, a.dept) =

                                                  (select distinct b.id, b.name_new, b.dept.new

                                                  from

                                                       table_2 b,

                                                       table_1 a

                                                  where

                                                       a.email in (select b.email from table_2 b) and (a.id) <> (b.id)

                                                  );

ERROR at line 6:

ORA-01427: single-row subquery returns more than one row

The only solution that I found if I add rownum <=1 but that is not a solution really because it returns only one row and updates everything by that one row which is incorrect it just proves that my query is working but I only wants to have one row.

Please suggest if I can rewrite the query any different so I can update my table.

Thank you.

This post has been answered by Cookiemonster76 on Oct 17 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2016
Added on Oct 16 2016
76 comments
32,363 views