这道题是我笨了,其实用一个左联接就可以解决了。sql语句如下:
SELECT dbo.PostComments.CommentId, dbo.PostComments.UserId,dbo.PostComments.PostId ,
dbo.PostComments.CommentDate, dbo.PostComments.Comment, dbo.PostComments.Ip, dbo.Users.Name
FROM dbo.PostComments Left outer JOIN
dbo.Users ON dbo.PostComments.UserId = dbo.Users.UserId where PostId=@postId |