FROM子句SQL中的嵌套SELECT语句

时间:2017-07-27 18:53:50

标签: mysql

我试图弄清楚这个SQL语句有什么问题。这是在我尝试添加到名为v3的数据库的过程结束时,上面定义了geneSymbolIn。我在最后WHERE上收到错误,说这是意外的。

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;

3 个答案:

答案 0 :(得分:0)

这不是一个有效的SELECT语句,official docs在描述正确的语法方面做得非常好。

答案 1 :(得分: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之前有一个逗号。

答案 2 :(得分:0)

假设您的FROM语句前面有SELECT

别名ET之后和WHERE子句之前还有一个额外的逗号不正确。

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;