错误 1248 (42000):每个派生的 table 必须有自己的别名,存在别名(内部查询组和具有)
ERROR 1248 (42000): Every derived table must have its own alias , alias are present (inner query with group and having)
我需要 select 非官方 lang-s 是官方语言两倍的国家,+ 官方是 2+
MYSQL 查询:
SELECT c2.countrycode , sum(c2.isOfficial) as isFalse
FROM countrylanguage as c2
INNER JOIN (
select c.countrycode , sum(c.isOfficial)as isOffTrue
from countrylanguage as c
where c.isOfficial='T'
group by c.countrycode
having sum(c.isOfficial)>1)
) as cisT
ON cisT.countrycode = c2.countrycode
where c2.isOfficial='F'
group by c2.countrycode
having sum(c2.isOfficial)>cisT.isOffTrue*2
但我收到别名错误,无法确定问题的根本原因,
你能帮我吗?
稍后....
RC: 额外 ) 加入
NExt 错误:无法识别内部 sum() 别名,请您帮忙?
SELECT c2.countrycode , sum(c2.isOfficial) as isFalse
FROM countrylanguage as c2
INNER JOIN (
select c.countrycode , sum(c.isOfficial) isOffTrue
from countrylanguage as c
where c.isOfficial='T'
group by c.countrycode
having sum(c.isOfficial)>1
) as cisT
ON cisT.countrycode = c2.countrycode
where c2.isOfficial='F'
group by c2.countrycode
having sum(c2.isOfficial)>(cisT.isOffTrue*2);
错误 1054 (42S22):'having clause'
中的未知列 'cisT.isOffTrue'
加法:
Table:
+-------------+---------------+------+-----+--------+
| Field | Type | Null | Key | Default |
+-------------+---------------+------+-----+---------+
| CountryCode | char(3) | NO | PRI | |
| Language | char(30) | NO | PRI | |
| IsOfficial | enum('T','F') | NO | | F |
+-------------+---------------+------+-----+---------+
我像下一个一样更改了查询并且成功了,购买我仍然没有得到之前失败的 RC
SELECT c2.countrycode, sum(c2.isOfficial) as isOffFalse, c1.isOffTrue
FROM (
select c0.countrycode, sum(c0.isOfficial)as isOffTrue
from countrylanguage c0
where c0.isOfficial='T'
group by c0.countrycode having sum(isOfficial)>1
) as c1, countrylanguage as c2
where c1.countrycode = c2.countrycode
and c2.isOfficial='F'
group by c2.countrycode
having sum(c2.isOfficial)>(c1.isOffTrue*2);
您正在加入
ON cisT.countrycode = c2.countrycode
但 cisT 中不存在国家代码列 table。
我需要 select 非官方 lang-s 是官方语言两倍的国家,+ 官方是 2+
MYSQL 查询:
SELECT c2.countrycode , sum(c2.isOfficial) as isFalse
FROM countrylanguage as c2
INNER JOIN (
select c.countrycode , sum(c.isOfficial)as isOffTrue
from countrylanguage as c
where c.isOfficial='T'
group by c.countrycode
having sum(c.isOfficial)>1)
) as cisT
ON cisT.countrycode = c2.countrycode
where c2.isOfficial='F'
group by c2.countrycode
having sum(c2.isOfficial)>cisT.isOffTrue*2
但我收到别名错误,无法确定问题的根本原因, 你能帮我吗?
稍后....
RC: 额外 ) 加入
NExt 错误:无法识别内部 sum() 别名,请您帮忙?
SELECT c2.countrycode , sum(c2.isOfficial) as isFalse
FROM countrylanguage as c2
INNER JOIN (
select c.countrycode , sum(c.isOfficial) isOffTrue
from countrylanguage as c
where c.isOfficial='T'
group by c.countrycode
having sum(c.isOfficial)>1
) as cisT
ON cisT.countrycode = c2.countrycode
where c2.isOfficial='F'
group by c2.countrycode
having sum(c2.isOfficial)>(cisT.isOffTrue*2);
错误 1054 (42S22):'having clause'
中的未知列 'cisT.isOffTrue'加法:
Table:
+-------------+---------------+------+-----+--------+
| Field | Type | Null | Key | Default |
+-------------+---------------+------+-----+---------+
| CountryCode | char(3) | NO | PRI | |
| Language | char(30) | NO | PRI | |
| IsOfficial | enum('T','F') | NO | | F |
+-------------+---------------+------+-----+---------+
我像下一个一样更改了查询并且成功了,购买我仍然没有得到之前失败的 RC
SELECT c2.countrycode, sum(c2.isOfficial) as isOffFalse, c1.isOffTrue
FROM (
select c0.countrycode, sum(c0.isOfficial)as isOffTrue
from countrylanguage c0
where c0.isOfficial='T'
group by c0.countrycode having sum(isOfficial)>1
) as c1, countrylanguage as c2
where c1.countrycode = c2.countrycode
and c2.isOfficial='F'
group by c2.countrycode
having sum(c2.isOfficial)>(c1.isOffTrue*2);
您正在加入
ON cisT.countrycode = c2.countrycode
但 cisT 中不存在国家代码列 table。