我正在建造一堵类似Facebook的墙,希望从当前用户和他们所有的朋友那里检索所有更新。
目前,我只从用户的朋友那里得到更新。如何包含用户自己的更新?
SELECT M.msg_id,
M.uid_fk,
M.message,
M.created,
U.fname,
U.lname,
M.uploads
FROM messages M INNER JOIN users_friends F ON F.friendID = M.uid_fk
AND F.userID = " . $_SESSION['user_id'] . "
AND F.status = 2
INNER JOIN users U ON U.userID = F.friendID
order by M.msg_id desc limit 10
SELECT <columns>
FROM (
SELECT <columns>
FROM <friends criteria>
UNION
SELECT <columns>
FROM <current user criteria>
) x
order by msg_id desc
limit 10