posts
ユーザーによるすべての投稿が保存されるテーブルがあります。このテーブルの構造は次のとおりです
| post_id | post_user | post_content | post_date |
ユーザーテーブルは次のとおりです
| user_id | username | user_joined |
ユーザー関係表は次のとおりです
| follower | following | rel_date |
これは、ユーザーがフォローしている人々から投稿を取得して表示するために使用しているクエリです。
SELECT * FROM posts WHERE post_user in(SELECT follower from user_follow where following=$loggedin_user)
次に、ユーザーに投稿を共有してもらいたいので、次のようにテーブル repost_user を作成しました
| repost_user | original_post_user | post_id | repost_date |
ユーザーがフォローしているユーザーからの投稿を取得したいのですが、これには再投稿も含まれます..どうすればよいですか?
編集:結果セットがどのように見えるか
post_id | post_content | post_user | post_date | is_repost | repost_user | repost_date
たとえば、通常の投稿の場合、行は次のようになります
23 | <some content> | 3 | <post date> | false | null | null |
その再投稿の場合、行は次のようになります
23 | <some content> | 3 | <post date> | true | 2 | <repost_date> |