Query to get reposts from people the user is following
SELECT p.*,r.repost_userr.repost_date,IF(r.post_id&gt;1,'true','false') FROM posts p 
left join repost_user r on p.post_id = r.post_id  
left join user_follow u on p.post_user = u.follower
where following=$loggedin_user; 


Regarding the performance implications of using union all in place of joins, please see this answer on Stack Overflow:

Inner Join versus Union All