梳理一下查找数据的逻辑:
1、找出关注者user_id等于1(以下统称关注者),其对应的被关注者id(即follower_id,以下统称被关注者)
select
follower_id
from follow
where user_id = 1
2、找出被关注者喜欢的音乐id
select
music_id
from music_likes as ml
join (
select
follower_id
from follow
where user_id = 1
) as t1
on ml.user_id = t1.follower_id
3、找出关注者已喜欢的音乐
select
music_id
from music_likes
where user_id = 1
4、找出被关注者喜欢但排除关注者喜欢的音乐的名字
select
music_name as name
from music
where id in (
select
music_id
from music_likes as ml
join (
select
follower_id
from follow
where user_id = 1
) as t1
on ml.user_id = t1.follower_id
where music_id not in (
select
music_id
from music_likes
where user_id = 1
)
)