Rumah > Artikel > pangkalan data > mysql-报Subquery returns more than 1 row求解决,紧急,紧急!!!
mysql
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'