ORA-01427: single-row subquery returns more than one row
OracleWhat does it mean?
A subquery expected to return a single row returned more than one row. For example, the subquery on the right side of an equality (=) comparison produced multiple values.
Why does it happen?
A subquery returning multiple rows where = or an assignment is expected; an insufficiently narrowed WHERE condition; a non-unique match in the correlation; a scalar subquery in the SELECT list returning multiple rows.
How to fix it
Narrow the subquery so it returns a single row (additional WHERE, unique key). If multiple values are really expected, use IN instead of =: WHERE id IN (SELECT id FROM ...). Or add an aggregate to the subquery (MAX, MIN), or reduce it to one row with ROWNUM = 1. First run the subquery on its own and check how many rows it returns.