SELECT POSTS.*
FROM POSTS
LEFT JOIN SUBSCRIBERS
ON POSTS.AUTHORID = SUBSCRIBERS.PROFILEID
WHERE POSTS.AUTHORID = ?
OR SUBSCRIBERS.SUBSCRIBERID = ?
ORDER BY POSTID DESC
LIMIT ?
The above is the query I’m using and this will select posts from the profiles a user is subscribed to. Now this works fine, but now I want to grab another column from another table.
In my third table USERS, I have an “AVATARID” which I want to access.
In my fetch loop for this query, it echos out the username of the post author, and the post body. What I want it to do is also echo out the avatarID of the user who wrote the post. I tried adding in another query inside my while loop, but I find that sloppy, and it also doesn’t work :S
So, simple question: How do I access the AvatarID from the table USERS with the USERID of the AUTHORID from the post?
Something like…