Click here to Skip to main content
14,934,895 members
Please Sign up or sign in to vote.
1.20/5 (2 votes)
See more:
I am implementing similar website like twitter.com and i have two table one having tweet information and one having followers information and i want to show data from tweet where in tweet table userid=@userid as well as in Followers table userid=FollowTOid.
for example:
in tweet table user id=1 and in followers table i want to know that userid 1s following list so in follow table userid(1)=FollowToid.

bcoz in twitters news feed we can see our own tweets as well as following tweet

so please tell me how i can write query for it in sql.
Posted

It looks like you want to join the two tables together like the following

SQL
select t.* from TweetTable t left join FollowerTable F on t.userid = f.followTOid where t.userid = @userid


There are different types of joins and your old friend google, will have lots of information on this subject
   
Select * from Tweet where userid in (select FollowToId from Follow where userid =@userid)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900