[英]MySQL Error Code 1111: Invalid use of group function
I get error code 1111 when I try and print the celebrities who do not follow anyone. 当我尝试打印不关注任何人的名人时,我收到错误代码1111。
user (email, password, name, date_of_birth, address, type)
primary key(email)
celebrity (email, website, kind)
primary key(email)
follow (follower,followee)
primary key(follower,followee)
foreign key(follower) references user(email)
foreign key(followee) references user(email))
SELECT DISTINCT(u.name)
FROM follow as f, user as u, celebrity as c
WHERE u.email = c.email and (0 > COUNT(f.followee))
ORDER by name DESC
you can't use column without aggregation function not mentioned in group 您不能使用没有聚集功能的组中未提及的列
if you want check for an aggregated function result you must use having and not where 如果要检查聚合函数结果,则必须使用Have而不是where
so you should use 所以你应该使用
SELECT u.name
FROM follow as f, user as u, celebrity as c
WHERE u.email = c.email
GROUP BY u.names
having 0 > COUNT(f.followee)
ORDER by name DESC
(but 0 > COUNT(f.followee) is no sense could be you need another condition for check count , and also your join clause seems not complete) (但是0> COUNT(f.followee)是没有意义的,因为您需要另一个条件来进行支票计数,并且您的join子句似乎不完整)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.