您要寻找的最好是作为两个不同的结果集......或两者的结合。
Select "friend" as src, author, post from friends f inner join streams s on s.author = f.id
union
Select "follower" as src, author, post from followers f inner join streams s on s.author = f.id
这只是一些伪编码,但它应该让您了解如何进行。在不知道您的数据库架构的情况下,这是我能提供的最好的。
编辑:
这可能就是你要找的东西
select user_id, contents_id, time from (
select user_id, contents_id, time
from followers f inner join stream s on s.user_id = f.user_id and f.user_id = "username"
union
select user_id, contents_id, time
from friends f inner join stream s on s.user_id = f.user_id and f.user_id = "username"
) order by time desc
这将按时间顺序返回数据,降序。