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

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

https://www.nowcoder.com/practice/048ed413ac0e4cf4a774b906fc87e0e7

# select  distinct c.music_name 
# from follow a inner join music_likes b on a.follower_id=b.user_id inner join music c on c.id=b.music_id
# where a.user_id=1 and b.music_id not in (select music_id from music_likes where user_id=1)
# order by c.id
# 当distinct和order by 同时使用会报错,因为先执行distinct再执行order by,当我们没法对去重前的数据进行排序,可以通过子查询进行解决
select music_name from 
(select  distinct c.music_name,c.id
from follow a inner join music_likes b on a.follower_id=b.user_id inner join music c on c.id=b.music_id
where a.user_id=1 and b.music_id not in (select music_id from music_likes where user_id=1)) t
order by id

全部评论

相关推荐

把实习生当正职使昨天第一天就加班,晚上连口饭都没吃上,以后日子咋过,我不想干了
码农索隆:实习不怕忙,就怕干的活重复且没难度,要干就干那种有深度有难度的任务,这样才能快速的提升
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务