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