Jump to content

Please help me to correct this query


sledjama

Recommended Posts

Hello, I am working on a facebook style news feed, the feed you get to see when when you login to facebook that shows posts made by you and your friends.

 

i am able to get posts made by friends with this query

 

select members.username, wallpost.idx, poster_id, `post`, wall_id, `time`, member_info.picture from wallpost, member_info, members, friends  where (( poster_id=friends.friend1_id and friends.friend2_id=?) or (poster_id=friends.friend2_id and friends.friend1_id=?)) and member_info.user_id=wallpost.poster_id and members.id=wallpost.poster_id order by idx desc LIMIT 0,50

getting data from 4 tables to fulfill what i want but it does not show posts made by me

my id will be inserted where the question marks are.

 

select members.username, wallpost.idx, poster_id, `post`, wall_id, `time`, member_info.picture from wallpost, member_info, members, friends  where (( poster_id=friends.friend1_id and friends.friend2_id=?) or (poster_id=friends.friend2_id and friends.friend1_id=?) [b]or poster_id=?[/b]) and member_info.user_id=wallpost.poster_id and members.id=wallpost.poster_id order by idx desc LIMIT 0,50

 

adding the bolded part helped but it fetched dupplicates of my own posts while posts from friends is fine.

 

thanks in advance

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.