2015-08-21 136 views
0

我試圖執行SQL查詢,但得到了「缺少右括號」錯誤:無法執行查詢

((SELECT CUST_ACCT 
    FROM CUSTMASTER 
    WHERE SITE_ID IN (SELECT SITE_ID FROM HOUSEMASTER WHERE FTAX=1)) 
    AND 
(SELECT CUST_ACCT 
    FROM CUSTMASTER 
    WHERE SITE_ID IN (SELECT SITE_ID FROM HOUSEMASTER WHERE MGT=1))) 

我覺得像括號內適當的檢查。請讓我知道缺少什麼?

+0

你可能想用表的說明和你正在尋找 –

回答

1

它看起來像你試圖通過增加它們之間的and運營商獲得來自兩個不同的查詢結果爲一體。這不起作用。您可以使用union查詢,但它看起來可以簡化爲下面的查詢。

也許這就是你真正想要的?

SELECT CUST_ACCT 
FROM CUSTMASTER 
WHERE SITE_ID IN (
    SELECT SITE_ID 
    FROM HOUSEMASTER 
    WHERE FTAX=1 OR MGT=1 
) 
0

我認爲必須UNION:

((SELECT CUST_ACCT 
    FROM CUSTMASTER 
    WHERE SITE_ID IN (SELECT SITE_ID 
        FROM HOUSEMASTER 
        WHERE FTAX = 1)) 
    UNION 
    (SELECT CUST_ACCT 
    FROM CUSTMASTER 
    WHERE SITE_ID IN (SELECT SITE_ID FROM HOUSEMASTER WHERE MGT=1))) 
0
SELECT CUST_ACCT FROM CUSTMASTER WHERE SITE_ID 
IN (SELECT SITE_ID FROM HOUSEMASTER WHERE FTAX=1 or MGT=1) 
+2

儘管此代碼可以回答這個問題的輸出編輯您的問題,提供有關爲什麼附加的上下文和/或該代碼如何回答這個問題可以提高其長期價值。 – JAL

0

我不知道到底會導致您的描述不詳細。

試試這個,如果你嘗試比較就像select (true and false)

選擇((SELECT CUST_ACCT FROM CUSTMASTER WHERE SITE_ID IN(SELECT SITE_ID FROM舍監WHERE FTAX = 1))AND(SELECT CUST_ACCT FROM CUSTMASTER WHERE SITE_ID IN(SELECT SITE_ID FROM舍監WHERE MGT = 1)))

相關問題