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

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

全部评论

相关推荐

2024-12-24 16:19
已编辑
东南大学 无线通信工程师
华为 无线工程师 n*16
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务