将三张表连接,通过子查询限定音乐ID即可 最外面嵌套一层查询的原因是distinct和orderby不能联用,因为distinct执行顺序优于orderby ,而前者根据查询结果生成一张虚拟表,是不包含orderby使用的字段的。可以将orderby字段加入select解决,但是不符合题目要求,所以再套一层查询解决这个问题。

from(
select distinct music_name,music_id
from follow F left join music_likes ML on F.follower_id=ML.user_id left join music M on M.id=ML.music_id
where F.user_id ="1" and music_id not in (select music_id from music_likes where user_id = 1 )
)B
order by music_id