user_table
user_id | username
1 | solomon
2 | muna
message table
id user_id| message
1 1 | this is my first message
2 1 | this is my seocnd message
3 2 | this is muna messgae
relationship table
leader | follower
1 | 2
|
what i want to do is a three table join to bring out muna's friend messages, currently muna is following solomon(as shown on the followers table),
so i want the display to be like this on mona homepage
Solomon "this is my my first message
----------------------------------
solomon "this is my second message"
p.s. this is just an example database, i just wanted to see how to approach the problem, and this is what i have attempted so far!
select username, message, leader
from user, message, relationship where user.user_id =notes.user_id
and user.user_id = relationship.leader and where user_id = $_SESSION['user_id']
*the session id is muna which is user_id 2