Hi All

We need some assistance in coding a function on our website that we are currently developing.

here is the problem in brief:

We have the following tables:

and other tables.

What is the SQL Query to load user activities that am following on my newsfeed section? we are building a newsfeed section just like the facebook one.
this is what we tried and it is not working:

SELECT * FROM users INNER JOIN likes ON (users.uId = likes.uId) INNER JOIN status ON
(users.uId = status.uId) WHERE EXISTS ( SELECT * FROM follow WHERE (like.uId=
follow.fUser2 AND follow.fUser1='5') OR (status.uId= follow.fUser2 AND
follow.fUser1='5') );

Any assistance can be appreciated in solving this issue, your services will be compensated for sure.