sql多欄位查詢 - sql select select



SQL單行子查詢返回多個行 (1)

下面的查詢應該從動畫中返回人物角色的名字。 但是我得到以下錯誤:

Blockquote ORA-01427:單行子查詢返回多行

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')))));

提前致謝!

https://ffff65535.com


代替

WHERE <field_name> = (SELECT ...

使用

WHERE <field_name> IN (SELECT ...

在查詢中有5個條件需要改變。

UPD還你的查詢相當於

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';




oracle11g