Hi there!
I have a problem that I can't figure out myself. I've tried using LEFT JOIN etc but nothing seems to work. I'm using MySQL so you know.
I'm building a little blogportal for me and my friends and all users have their own blog.
database:
users: id, username, password, etc
blog: id, title, text, user_id, etc
relations follower_id, following_id
I query my own blogposts like this:
SELECT * FROM microblog WHERE user_id = {$user_id} ORDER BY posted DESC
and i list my friends like this:
SELECT * FROM users, relations WHERE relations.follower_id = {$user_id} AND relations.following_id = users.id
That was the easy part. BUT.
I rather JOIN the tables somehow because I also want to list my friends blogposts inside my loop. But I don't just want the post to show, I also want some info about the user that posted that one so then I must get some info from the users table as well. And that's what bothers me! I can't figure it out.
In short: I want to list my own blog posts and all the users I'm friend with within my own loop. And I also want to display username and email beside the posts.
Hope you understand what I mean.
/Tobias
Sweden