1
votes

The following query should return the name of persons voice-acting a character from an anime. But I get the following error:

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

SELECT P.NAME, 
FROM DBS_PERSON P
WHERE P.ID = (
    SELECT VA.PERSON_ID
    FROM DBS_VOICEACTOR VA
    WHERE VA.PERSON_ID = (
        SELECT AA.PERSON_ID
        FROM DBS_ACTSAS AA
        WHERE AA.CHARACTER_ID = (
            SELECT C.ID
            FROM DBS_CHARACTER C
            WHERE C.ID = (
              SELECT PI.CHARACTER_ID
              FROM DBS_PLAYSIN PI
              WHERE PI.SERIE_ID = (
                SELECT S.ID
                FROM DBS_SERIE S
                WHERE S.ID = '1')))));

Thanks in advance!

1

1 Answers

1
votes

Instead of

WHERE <field_name> = (SELECT ...

Use

WHERE <field_name> IN (SELECT ...

There is 5 conditions to change in your query.

UPD Also your query is equivalent to

SELECT P.NAME
FROM DBS_PERSON P
     join DBS_ACTSAS AA  on P.PERSON_ID = AA.PERSON_ID
     join DBS_PLAYSIN PI on AA.CHARACTER_ID = PI.CHARACTER_ID
     join DBS_SERIE S    on PI.SERIE_ID = S.ID
WHERE S.ID = '1';