Hello every one
I fall in mistake
Please help me
I have 3 table
1 – User (id, email)
2 – Friend (sender, receiver, state)
3 – Post (sender, text, date)
Now
I want to select User (id), Post (*)
But
Select user’s post who is login and the other guy that receive a request for follow from the user and my code is:
Create PROCEDURE showpost
@email nvarchar (50)
AS
BEGIN
Select User.Code as code, post.* from post, friend, User where (User.email=post.sender) and ((friend.sender=@email or friend.reciver=@email) and state='ok' and (post.sender=friend.sender or post.sender=friend.reciver)) order by post.code desc
END
This is a problem
When show post the user’s post will be Repeated as many as his request for follow
Attached file is better

Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 27, 2015, 5:48 PM EDT
Select DISTINCT User.Code as code, post.* from post, friend, User where (User.email=post.sender) and ((friend.sender=@email or friend.reciver=@email) and state='ok' and (post.sender=friend.sender or post.sender=friend.reciver)) order by post.code desc
i also try this method for your tables and found correct o/pBhushan BhasmeRank #2,348 · 604 reputationPosted Jun 27, 2015, 3:21 AM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 27, 2015, 9:03 AM EDT
nofact noface13 reputationPosted Jun 27, 2015, 4:07 PM EDT
nofact noface13 reputationPosted Jun 28, 2015, 3:41 PM EDT