嵌套查询问题,无效标识符错误

时间:2013-10-01 14:50:44

标签: sql oracle10g inner-join

我在Oracle 10 XE中运行以下查询并获取 [Err] ORA-00904:“Q”:标识符无效

SELECT questions.sb_title Q,questions.sb_baab_id,questions.sb_fasal_id,QUESTIONS.SB_CONTENT answer,IST.SB_PREFERENCE PREF
FROM USER_QUESTIONS questions
INNER JOIN USER
ON QUESTIONS.SB_USER_ID = USER.SB_ID
INNER JOIN IST 
ON IST.SB_ID = USER.SB_IST_ID
AND(Q  LIKE '%where is%') 
AND USER.SB_IST_ID = 
(
    Select issued.SB_IST_ID
    FROM USER_REGISTER register_number
    INNER JOIN USER_ISSUED issued
    ON register_number.SB_REGISTER_NUMBER = ISSUED.SB_REGISTER_NUMBER
    AND REGISTER_NUMBER.SB_REGISTER_NUMBER IN(1240)
)

2 个答案:

答案 0 :(得分:1)

您无法在JOIN条件中引用别名 - 写下实际的列名:sb_title。

答案 1 :(得分:0)

我认为你不能像那样使用别名“Q”。您在select子句中对它进行别名,不要认为您可以在ON子句中使用该别名。尝试使用完整列名称(sb_title)。