I'm trying to make an MySQL query that will display mini-blogs from Me and My friends. Just like Twitter.
Here are my tables;
--members
m_id INT
m_user VARCHAR
(rest are other member info)
--shouts
s_id INT
s_userid INT
s_content TEXT
s_posted DATETIME
--friends
f_userid INT
f_friendid INT
f_status INT // 0=pending, 1=approved
f_create DATETIME
f_update DATETIME
Note: there are 2 entries for 1 friendship
ex: f_userid = ME, f_friendid = MYFRIEND and is vice-versa
f_userid = MYFRIEND, f_friendid = ME
The code that works, but doesn't use the friendlist table is;
SELECT * FROM shouts
JOIN members
ON members.m_id = shouts.s_uid
ORDER BY s_posted DESC
having trouble adding in the friends table info.
I believe i'm just missing one line of code or 2...
I've tried this, but failed.
SELECT * FROM shouts
JOIN members
ON members.m_id = shouts.s_uid
JOIN friends
ON friends.f_friendid = members.m_id
WHERE m_id = 1 //my id
AND f_userid = 1 //my id
AND f_status = 1
ORDER BY s_posted DESC