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
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pankaj Kumar ChoudharyPosted Jun 27, 2015, 9:48 PM
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/pnofact nofacePosted Jun 28, 2015, 7:41 PM
nofact nofacePosted Jun 27, 2015, 8:07 PM
Pankaj Kumar ChoudharyPosted Jun 27, 2015, 1:03 PM
Bhushan BhasmePosted Jun 27, 2015, 7:21 AM