我在這裏有一個共同的情況。我想爲特定用戶選擇所有帖子及其評論。例如:爲特定用戶選擇所有帖子及其評論
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