我在这里有一个共同的情况。我想为特定用户选择所有帖子及其评论。例如:为特定用户选择所有帖子及其评论
1)
Post:
1(PostId), SomeTitle, SomeText
2(PostId), SomeTitle, SomeText
Comments:
1, 1(PostId), CommentTitle, CommentText, UserId(1 - from another table)
2, 1(PostId), CommentTitle, CommentText, UserId(1 - from another table)
3, 2(PostId), CommentTitle, CommentText, UserId(2 - from another table)
4, 2(PostId), CommentTitle, CommentText, UserId(2 - from another table)
我想选择,例如,首先发布在一个结果集中,然后在用户id的另一个结果集中发表评论。总之,我想选择所有用户评论的帖子及其评论。谁能帮我?我想创建一个与userId和postId作为参数的SP,但我有问题。
所有职位相关的任何意见+的带有注释的呢?或某个用户发布的所有帖子?如果是这样,邮政记录如何与用户相关联? – 2014-10-08 20:08:34
只有用户评论的帖子。用户无法发布新帖子,因此帖子和用户表之间没有关系。 – user1797770 2014-10-08 20:12:18
提示,使用'外键'和'加入' – 2014-10-08 20:13:45