mutual-friendship

Finding mutual friend sql

牧云@^-^@ 提交于 2020-01-04 06:37:12
问题 actually i have 2 tables the friend table and the users table what i try to achieve is to retreive my mutual friend by checking the friend of another user and get the data of these mutual friend from the users table table friend is build like this id | user1 | user2 | friend_status then the table data looks like this 1 | 1 | 2 | 1 2 | 1 | 3 | 1 3 | 2 | 3 | 1 4 | 1 | 4 | 1 5 | 2 | 4 | 1 Then let's say that I am the user with id 2, then in that table I have 3 friends - 1, 3 and 4. What I want

newbie : getting mutual likes and only if they are mutual with active record?

岁酱吖の 提交于 2019-12-25 04:59:31
问题 What would be a good way to get mutual likes ? where 2 users like each other ( as in a friendlist) and get only those users who have a mutual match? user_id | likes_id 1 2 2 1 Only get results where both of the users likes each other ( friendship ) I have tried some join's but can't really get it to work, is there a building AR feature to get the above results? 回答1: To add to jexact's answer this is one way you can do this using AR: Like.joins('join likes l on likes.user_id=l.likes_id and l

rails activerecord, friend relation + inverse_friend relation how to get the mutual relation? code included

不想你离开。 提交于 2019-12-23 04:11:20
问题 Trying to find the mutual relation, In a friends relations, Already have friends and inverse_friends. But how to combine them to get the mutual friends? Cannot seem to figure it out I tried several options and searched long time online, just don't see it has_many :friendships has_many :friends, :through => :friendships has_many :inverse_friendships, :class_name => "Friendship", :foreign_key => "friend_id" has_many :inverse_friends, :through => :inverse_friendships, :source => :user how to get

neo4j - user suggestion with mutual count

纵然是瞬间 提交于 2019-12-13 08:14:56
问题 I have created 5 nodes in neo4j as follows. Node 1 {userid:1000, username: A, someOtherProperties...} Node 2 {userid:2000, username: B, someOtherProperties...} Node 3 {userid:3000, username: c, someOtherProperties...} Node 4 {userid:4000, username: D, someOtherProperties...} Node 5 {userid:5000, username: E, someOtherProperties...} Node 1 connected with Node 2 & 3, and Node 2 connected with node 1, 3, 4 1 -> 2 1 -> 3 2 -> 1 2 -> 3 2 -> 4 3 -> 4 Now I want user suggestion for node 1 which

rails activerecord, friend relation + inverse_friend relation how to get the mutual relation? code included

时光总嘲笑我的痴心妄想 提交于 2019-12-06 16:00:21
Trying to find the mutual relation, In a friends relations, Already have friends and inverse_friends. But how to combine them to get the mutual friends? Cannot seem to figure it out I tried several options and searched long time online, just don't see it has_many :friendships has_many :friends, :through => :friendships has_many :inverse_friendships, :class_name => "Friendship", :foreign_key => "friend_id" has_many :inverse_friends, :through => :inverse_friendships, :source => :user how to get a has_many :mutual_friends ? I don't think you can define a mutual friends association. So, let's look

MYSQL select mutual friends

梦想与她 提交于 2019-11-28 02:01:30
问题 My 'friends' table has the following columns: id, userID, userID2, state userID and userID2 don't have a specific order of being put into the database. I currently use this query to find a users friends: $quer = mysql_query(" SELECT CASE WHEN userID=$id THEN userID2 ELSE userID END AS friendID FROM friends WHERE userID=$id OR userID2=$id"); I have tried this however it doesn't work: SELECT CASE WHEN userID=$id OR userID=$session THEN userID2 ELSE userID END AS friendID FROM friends WHERE