select distinct a.music_name from
(select distinct m.music_name, ml.music_id
from music m
inner join
music_likes ml
on m.id=ml.music_id
where m.id not in (
    select music_id
    from music_likes
    where user_id=1

)
and ml.user_id in (
    select follower_id
    from follow
    where user_id=1
)
order by ml.music_id
) a

  • 得到用户1的关注
  • 得到用户1的喜欢歌曲
  • 选取用户1的关注的喜欢歌曲以及去除用户1的喜欢歌曲
  • 套一层循环用来排序