【问题标题】:Something syntactically wrong with this SQL statement?这个 SQL 语句在语法上有什么问题吗?
【发布时间】:2013-04-13 02:14:24
【问题描述】:

当我尝试在 mysqlite3 中运行此查询时,我不断收到错误:

SELECT Region_DESC, AgeGroup, Population
(select REGION, sum(POPULATION) as Population, '0-15' AS AgeGroup
from STATS
Where Age between 0 and 15
group by REGION
union
Select REGION, SUM(POPULATION) as Population, '16-30' As AgeGroup
from STATUS
Where Age between 16 and 30
group by REGION) s
join REGION on REGION_CD = REGION

我收到以下错误: 错误:“SELECT”附近:语法错误

从语法上看,查询有什么问题吗?

【问题讨论】:

标签: sql syntax sqlite


【解决方案1】:

您在“人口”一词之后缺少FROM

【讨论】:

    【解决方案2】:

    您的查询是错误的。你基本上有:

    SELECT something
    (select somethingelse FROM somethingelsetable) s
    join REGION on REGION_CD = REGION
    

    我猜你在括号前缺少 FROM...

    【讨论】:

      【解决方案3】:

      不正确的查询 ... 第一行中缺少 From 子句。

      【讨论】:

      • @MarkLinus 答案与其他答案有何不同?你能解释一下吗
      猜你喜欢
      • 1970-01-01
      • 2011-08-28
      • 2014-05-08
      • 1970-01-01
      • 1970-01-01
      • 2012-07-07
      • 2012-05-02
      • 2013-11-06
      • 1970-01-01
      相关资源
      最近更新 更多