Mysql
 sql >> Database >  >> RDS >> Mysql

Ottieni risultati dai miei post e dai miei amici

Che ne dici?

select 
    u.username, 
    u.email, 
    m.title, 
    m.text 
       -- ... etc
from microblog m
     inner join user u on m.user_id = u.id
where  m.user_id = {$user_id} 
    or m.user_id in (select 
                         following_id 
                     from relations r 
                     where follower_id = {$user_id}
                    );