报Subquery returns more than 1 row求解决,紧急,紧急!!!

SELECT
*
FROM
mr_user_info u,mr_visit_info f,
(
SELECT
CASE
WHEN v.RELATION_TYPE = 2 THEN
(
select io.VISIT_ID from mr_visit_info io,mr_item_info_fb aa where io.RELATION_ID = aa.ITEM_ID and aa.ORG_ID = '001' and v.VISIT_ID = io.VISIT_ID
)

WHEN v.RELATION_TYPE = 1 THEN
(select vq.VISIT_ID from mr_beauty_org_info_fb bof,mr_visit_info vq where vq.RELATION_ID = bof.org_id AND bof.org_id = '001')
when v.RELATION_TYPE = 3 THEN
(select vq.VISIT_ID from mr_visit_info vq,mr_doc_info_fb doc where doc.org_id = '001' and doc.doc_id = vq.RELATION_ID)
END vid,
CASE
WHEN v.RELATION_TYPE = 1 THEN
(SELECT
fb.ORG_NAME
FROM
bione_org_info fb,mr_visit_info v,mr_beauty_org_info_fb bp
WHERE
v.RELATION_ID = bp.org_id and fb.org_no = bp.org_id and bp.ORG_ID = '001'
)
WHEN v.RELATION_TYPE = 2 THEN
(
SELECT
i.ITEM_NAME
FROM
mr_item_info_fb i,mr_visit_info v
WHERE
v.RELATION_ID = i.ITEM_ID and i.ORG_ID = '001'
)
WHEN v.RELATION_TYPE = 3 THEN
(
SELECT
b.TRUE_NAME
FROM
mr_doc_info_fb b,mr_visit_info v
WHERE
v.RELATION_ID = b.doc_id and b.ORG_ID = '001'
)
END visitName
FROM
mr_visit_info v
) ff
WHERE
ff.vid = f.visit_id
and f.user_id = u.user_id
AND f.relation_id != '0'

2个回答

你有一个子查询中可能返回多个记录,而语法需要只能返回唯一值

kongdechen
Vincentrz 那您帮我看看呗,我真不会了
4 年多之前 回复

一个要求返回一个值的语句反悔了多个值

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐