0

我正在尝试选择用户关注者。作为

SELECT     
profil_id, 
profil_user_id, 
profil_fullname, 
profil_puan, 
profil_aciklama, 
UserId,
UserName
COUNT(select follower_id  from follow where followed_id='2') as follower

FROM         
profil ,aspnet_Users
WHERE
profil_user_id ='2' and
profil.profil_user_id=aspnet_Users.UserID

我想选择关注者数量,但它不起作用。错误:*关键字“as”附近的语法不正确。* 问题出在哪里?(我不想使用左连接它有问题)

4

2 回答 2

3

代替

COUNT(select follower_id  from follow where followed_id='2') as follower

(select COUNT(follower_id)  from follow where followed_id='2') as follower
于 2013-04-28T18:33:18.397 回答
3

你错过了一个,之后UserName

UserName // <-- missed ',' here
COUNT(select follower_id  from follow where followed_id='2') as follower

此外,这不是有效的 sql server 查询

COUNT(select follower_id  from follow where followed_id='2') as follower

一个有效的选择是遵循 Danila 的代码

于 2013-04-28T18:35:30.163 回答