题解 | #网易云音乐推荐(网易校招笔试真题)#
网易云音乐推荐(网易校招笔试真题)
http://www.nowcoder.com/practice/048ed413ac0e4cf4a774b906fc87e0e7
- 参考答案
select music_name from music
where id in (
select music_id from music_likes
where user_id in(
select follower_id from follow
where user_id = 1)
and
music_id not in (select
music_id from music_likes
where user_id = 1)
)
- 答案解析
- 找到user_id=1关注的人:
select follower_id from follow
where user_id = 1
- 找到他专注的人喜欢的音乐id,并且去除他喜欢的音乐id
select music_id from music_likes
where user_id in(
select follower_id from follow
where user_id = 1)
and
music_id not in (select
music_id from music_likes
where user_id = 1)
3.查询音乐名字,上面两步就是限制条件