Help needed to construct a SQL query

Posted by song202y on Stack Overflow See other posts from Stack Overflow or by song202y
Published on 2010-04-07T19:01:12Z Indexed on 2010/04/07 19:03 UTC
Read the original article Hit count: 221

Filed under:

Need your help to get the list of suggested friends (who aren't friends of the current user but are friends of 2 or more of the current user's friends). The primary ordering should put people at the same school at the top, and the secondary ordering should put people with more common friends (that is, the number of people who are friends of that person and the current user) near the top.

Users: user_id PK, user_name

Profiles: user_id PK, school_name, ...

Friendships: id PK, user_id FK, friend_id FK

Thank you in advance.

Joe

© Stack Overflow or respective owner

Related posts about mysql-query