I am trying to make a script which will display the latest posts from my friends AND me. There are 3 tables related to this - statusUpdates (contains posts), friends (links between friends using IDs) and users (contains details of all users of the website). The script I am using at the moment is as follows.
$myQuery = mysql_query ("SELECT * FROM statusUpdates AS su
LEFT JOIN (friends AS fr) ON
(fr.frHostID = su.authorID OR fr.frContactID = su.authorID)
WHERE (fr.frHostID = 105090)
GROUP BY su.statusID
ORDER BY su.statusID
DESC LIMIT 0,5");
Please note that 105090 is my own ID.
Problem is that when I have no friends, not even a single post is showing up even though I have made more than one status update.
A solution would be to create a row in the friends table, adding me as my own friend. But in that case, I would have to prevent my own name from occuring in a "Show List of Friends" page, and any other related page.
I was initially using INNER JOIN
and having the above problem. Then I came a similar issue, and modified my script with LEFT JOIN
as was suggested. It seemed to have solved the issue of the OP of that post, but not mine.
I cannot submit comments in that post (probably because it is 2 years old). So I am creating this post.