中级农民
- 积分
- 101
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2017-1-28
- 最后登录
- 1970-1-1
|
本帖最后由 xiayu64 于 2019-12-11 00:27 编辑
it works:
Select a1.userid1, a2.userid2, count(a1.songid) as common_song. Waral dи,
From (select distinct a.userid1, songid
From friend a join song b on a.userid1 = b.userid) a1
join (select distinct a.userid2, songid
from friend a join song b on a.userid2 = b.userid) a2
on a1.songid = a2.songid . Χ
join friend c
on c.userid1 = a1.userid1 and c.userid2 = a2.userid2
group by a1.userid1, a2.userid2
having count(a1.songid) >= 2;
|
|