SQL selecting people you may know

SQL selecting people you may know,第1张

SQL selecting people you may know

use this EDIT

SELECt `friend_id` AS `possible_friend_id`FROM `friends`WHERe `player_id` IN (        --selecting those who are known    SELECT `friend_id`        --by freinds of #1    FROM `friends`    WHERe `player_id` = 1) AND `friend_id` NOT IN (      --but not those who are known by #1    SELECt `friend_id`    FROM `friends`    WHERe `player_id` = 1)AND NOT `friend_id` = 1       --and are not #1 himself        --if one is known by multiple people        --he'll be multiple time in the listGROUP BY `possible_friend_id` --so we groupORDER BY COUNT(*) DESC        --and order by amount of repeatings


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5675386.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-17
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存