我有 3 个表用户,流式传输并关注
下表:
follow_id user_id_follower user_id_followed
1 9 2
2 9 4
用户表
id username
1 test1
2 test2
流表
id user_id post_content post_image
1 9 Hi there uploads/1.jpg
2 9 Another uploads/2.jpg
这给了用户帖子
SELECT users.username, stream.post_content, stream.post_image
FROM users INNER JOIN stream ON users.id=stream.user_id
WHERE stream.user_id = 9
这给了用户关注帖子的人
SELECT users.username, stream.post_content, stream.post_image,
follow.user_id_follower, follow.user_id_followed FROM follow
INNER JOIN stream ON follow.user_id_followed = stream.user_id
INNER JOIN users ON follow.user_id_followed = users.id
WHERE follow.user_id_follower = 9 // this change depending on user
我在制作一个同时获取用户和关注的帖子的 SQL 语句时遇到问题