我对下面的查询有疑问,在主SELECT中无法检索ENTITY_ID的值 ,因为我使用 LIKE 我得到的结果不止一个。我该如何克服呢?如果我放置一个内部 SELECT,例如:
(
SELECT
SEC_NN_SERVER_T.SRV_ID
FROM
SEC_NN_SERVER_T
WHERE
UPPER(SEC_NN_SERVER_T.SRV_NAME) LIKE UPPER('%gen%') ) AS ENTITY_ID,
我犯了同样的错误:
“ORA-01427:单行子查询返回多行”。
他是完整的查询:
SELECT DISTINCT
SEC_USER.USR_ID AS USR_ID,
SEC_USER.USR_FIRST_NAME AS USR_FIRST_NAME,
SEC_USER.USR_LAST_NAME AS USR_LAST_NAME,
SEC_USER_PRIV.ROLE_ID AS SYSTEM_ROLE_ID,
21 AS ENTITY_TYP_CODE,
(
SELECT
SEC_NN_SERVER_T.SRV_ID
FROM
SEC_NN_SERVER_T
WHERE
UPPER(SEC_NN_SERVER_T.SRV_NAME) LIKE UPPER('%gen%') ) AS ENTITY_ID
FROM
SEC_USER_PRIV,
SEC_USER
WHERE
SEC_USER.USR_ID = SEC_USER_PRIV.USR_ID
AND ((
SEC_USER_PRIV.ENTITY_TYP_CODE = 21
AND SEC_USER_PRIV.ENTITY_ID IN (
(
SELECT
SERVER_T.SRV_ID
FROM
SERVER_T
WHERE
UPPER(SERVER_T.SRV_NAME) LIKE UPPER('%gen%') ))))
请协助提前谢谢。