php - Get results from my own and "friends" posts -
I have a problem that I can not understand myself I have tried to use LEFT JOIN, etc. but nothing works
Database:
I am using my MySQL so that you know.
I am creating a small blogport for myself and my friends.
User: ID, username, password, etc
blog: ID, title, text, user_id, etc.
< P> Relationships Followers_ID, the following_idI like to ask my own blog posts like this:
Select from Microblog with WHERE User_id = {$ user_id} posted by the ORDER DESC
and I list my friends like this:
choose, user Relations, where relationship Faller_ID = {$ user_id} and relations.following_id = Users.id
This was an easy part. but.
I am not in any way in the tables because I want to list my friends' blogposts even within my loop. But I just do not want to show the post, I also want some information about the user who made a post, then I should also get some information from the user table. And that makes me bother! I can not understand it.
In short: I want to list my own blog posts and I am making friends within my own loop.
/ Tobias
Sweden
>
How about?
Select u.username, u.email, m.title, m.text - ... etc can join microblog m at m.user_id = u.id on user u Where m.user_id = {$ user_id} or m.user_id (select following_id from relations, where follower_id = {$ user_id});
Comments
Post a Comment