如题,出问题的是(ArticleNum个人文章篇数;PhotoNum个人照片总数)代码如下:select UserName,E.UserLoginID,online,UserNC,ArticleNum=(select count(*) from blog_Comment where UserLoginID=E.UserLoginID),PhotoNum=(select count(*) from blog_PComment where UserLoginID=E.UserLoginID),JoinDate,Privacy,Point,LastLoginTime from Emp_Employee E where UserType=2 and UserName=@UserName
select UserName,E.UserLoginID,online,UserNC,ArticleNum=(select count(*) from blog_Comment where UserLoginID=@UserLoginID),PhotoNum=(select count(*) from blog_PComment where UserLoginID=@UserLoginID),JoinDate,Privacy,Point,LastLoginTime from Emp_Employee E where UserType=2 and UserName=@UserName
楼主使用的是表关联,当然得出的是全部数据,而不是一个特定的值,应该再传入一个参数@UserLoginID
或者可以直接用@UserLoginID取代@UserName来做参数
select UserName,E.UserLoginID,online,UserNC,ArticleNum=(select count(1) from blog_Comment where UserLoginID=@UserLoginID),PhotoNum=(select count(1) from blog_PComment where UserLoginID=@UserLoginID),JoinDate,Privacy,Point,LastLoginTime from Emp_Employee E where UserType=2 and UserLoginID=@UserLoginID
这条语句应该没错吧