题解 | 网易云音乐推荐(网易校招笔试真题)
WITH a AS ( SELECT DISTINCT m.id, m.music_name FROM music_likes AS ml LEFT JOIN follow AS f ON f.user_id = ml.user_id JOIN music AS m ON ml.music_id = m.id WHERE ml.user_id IN ( SELECT follower_id FROM follow WHERE user_id = 1 )) SELECT music_name FROM a WHERE music_name NOT IN ( SELECT m.music_name FROM music_likes AS ml LEFT JOIN follow AS f ON f.user_id = ml.user_id JOIN music AS m ON ml.music_id = m.id WHERE ml.user_id = 1 ) ORDER BY id ASC