题解 | #网易云音乐推荐(网易校招笔试真题)#

网易云音乐推荐(网易校招笔试真题)

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)
)
  • 答案解析
  1. 找到user_id=1关注的人:
select follower_id from follow
    where user_id = 1
  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.查询音乐名字,上面两步就是限制条件

全部评论

相关推荐

点赞 评论 收藏
转发
投递字节跳动等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务