2017-07-27 83 views
-1

我想弄清楚這個SQL語句有什麼問題。這是在我試圖添加到名爲v3的數據庫和geneSymbolIn在上面定義的過程結束時進行的。我在最後的WHERE上發生錯誤,表示這是意外的。FROM子句中的嵌套SELECT語句SQL

FROM (SELECT Probe_gene, logFC, adj_P_Value, gene, Study_ID, Group1, Group2 FROM v3.degContrastList WHERE gene = geneSymbolIn) AS CL, 
    (SELECT Study_ID, Disease, PMID, Time_Point, Treatment, Raw_Data FROM v3.degContrastListExperiment) AS ET, 
    WHERE CL.Study_ID = ET.Study_ID; 
+0

見https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very -simple-sql-query – Strawberry

+0

@Kyle - 如果我的解決方案已解決您的問題,請接受答案並投票表決! – JRG

回答

0

這不是一個有效的SELECT語句中,official docs做概述了正確的語法的一個不錯的工作。

+0

哪一個是無效的? –

+1

整個事情,哦......等等,它不是完整的查詢,並且使用了幾十年前的「逗號連接」語法讓我失望。問題是你在第二個子查詢後得到一個逗號。 – Uueerdo

+0

微小的逗號將是我的死......謝謝! –

0

如果您正確格式化代碼,很明顯代碼有什麼問題。

FROM (
    SELECT Probe_gene, logFC, adj_P_Value, gene, Study_ID, Group1, Group2 
    FROM v3.degContrastList 
    WHERE gene = geneSymbolIn 
) AS CL, 
(
    SELECT Study_ID, Disease, PMID, Time_Point, Treatment, Raw_Data 
    FROM v3.degContrastListExperiment 
) AS ET, 
WHERE CL.Study_ID = ET.Study_ID; 

首先,沒有SELECT聲明。其次,在WHERE之前有一個逗號。

0

假設您的FROM聲明之前有一個SELECT

別名ETWHERE子句之後有一個額外的逗號,這是不正確的。

FROM (SELECT Probe_gene, logFC, adj_P_Value, gene, Study_ID, Group1, Group2 
     FROM v3.degContrastList 
     WHERE gene = geneSymbolIn) AS CL, 
    (SELECT Study_ID, Disease, PMID, Time_Point, Treatment, Raw_Data 
     FROM v3.degContrastListExperiment) AS ET 
WHERE CL.Study_ID = ET.Study_ID;