暂时想到的是设计两张表
user 表(用户表)
id user
1 张三
2 李四
3 王五
4 赵六
friend 表(会员关系表)
id uid fid
1 1 2
2 1 3
3 2 1
4 4 2
5 4 3
如果要查找好友
select * from friend where uid='张三' or fid='张三'
查找好友数最多的前三个人
select * from user a,friend b where a.id = b.uid
and a.id in(
select uid count(*) AS cn
FROM friend GROUP BY
uid ORDER BY cn
desc LIMIT 3
)
好像不对,请高手指教。。。