Mysql 什么';这个语法怎么了?
我使用的是MYSQL 5.7您不能在Mysql 什么';这个语法怎么了?,mysql,sql,Mysql,Sql,我使用的是MYSQL 5.7您不能在where子句中使用聚合函数。您需要一个具有子句: select count(*),snum from enrolled group by snum where count(*)=(select count(distinct(cname)) from enrolled;); select count(*), snum from enrolled group by snum having count(*) = (select count(distinct c
where
子句中使用聚合函数。您需要一个具有
子句:
select count(*),snum from enrolled group by snum where count(*)=(select count(distinct(cname)) from enrolled;);
select count(*), snum
from enrolled
group by snum
having count(*) = (select count(distinct cname ) from enrolled);
此外,查询结束时只能显示一个分号。而且,尽管这不是语法错误,
distinct
不是函数,所以它不需要括号 不能在where
子句中使用聚合函数。您需要一个具有
子句:
select count(*),snum from enrolled group by snum where count(*)=(select count(distinct(cname)) from enrolled;);
select count(*), snum
from enrolled
group by snum
having count(*) = (select count(distinct cname ) from enrolled);
此外,查询结束时只能显示一个分号。而且,尽管这不是语法错误,
distinct
不是函数,所以它不需要括号 不能在where
子句中使用聚合术语。相反,您应该使用having
子句:
select count(*),snum from enrolled group by snum where count(*)=(select count(distinct(cname)) from enrolled;);
select count(*), snum
from enrolled
group by snum
having count(*) = (select count(distinct cname ) from enrolled);
不能在
where
子句中使用聚合术语。相反,您应该使用having
子句:
select count(*),snum from enrolled group by snum where count(*)=(select count(distinct(cname)) from enrolled;);
select count(*), snum
from enrolled
group by snum
having count(*) = (select count(distinct cname ) from enrolled);