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

SELECT DISTINCT music_name
FROM (SELECT DISTINCT f.user_id, follower_id, music_id
      FROM follow f
      LEFT JOIN music_likes ml ON follower_id = ml.user_id
      WHERE f.user_id = 1
      ORDER BY music_id
      ) a
INNER JOIN music ON a.music_id = music.id
WHERE music_id NOT IN (SELECT music_id
                       FROM music_likes
                       WHERE user_id = 1);

注:理清f表中的关注关系。

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务