当我尝试打印不跟随任何人的名人时,我收到错误代码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
答案 0 :(得分:0)
您不能使用未在组
中提及的聚合功能的列如果要检查聚合函数结果,则必须使用having而不是where
所以你应该使用
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
(但是0&CO; COUNT(f.followee)是没有意义的,你可能需要另一个检查计数条件,而且你的连接子句似乎还没有完成)