本文介绍了SQL单行子查询返回多于一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下查询应返回为动漫角色配音的人的姓名.但我收到以下错误:
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:单行子查询返回多于一行
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')))));
提前致谢!
推荐答案
代替
WHERE <field_name> = (SELECT ...
使用
WHERE <field_name> IN (SELECT ...
您的查询中有 5 个条件可以更改.
There is 5 conditions to change in your query.
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';
这篇关于SQL单行子查询返回多于一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!