database - Twitter style following-follower table in SQL-2 -
addition twitter style following-follower table in sql
in upper example able return query "if userb following other users follows him"
i need simpler thing now. tried modify original code without luck. need "if userb following or not of users , regardless if follow him. returns null people dont follow particular user.
this sample table users
id user_id 1 usera 2 userb 3 userc 4 userd 5 usere
this sample table follows
id user_id follower_id 1 usera userb 2 userd userb
i return result includes follower/following state. example userb (he follows , d not c , e:
id followedby arewefollowing 1 usera 1 2 userb 0 3 userc 0 4 userd 1 5 usere 0
thanks help!
arda
you can take count second table situation -
select id,user_id, ( select count(*) follows follows.user_id = users.user_id , follows.follower_id = 'userb') arewefollowing users
Comments
Post a Comment