#follow表:user_id, follower_id
#music_likes表:user_id, music_id
#music表: id, music_name
#首先返回用户1关注的人
select follower_id from follow where user_id = 1;
#然后看用户1的人喜欢哪些歌,并排除在外
select music_id from music_likes where user_id = 1;
#其次找出所关注人喜欢的歌并排除user_id所喜欢的歌
select music_id from music_likes
where user_id
in(select follower_id from follow where user_id = 1)
and music_id not in(select music_id from music_likes where user_id = 1);
#最后的结果代码
select distinct m.music_name
from music m
join (select music_id from music_likes
where user_id
in(select follower_id from follow where user_id = 1)
and music_id not in(select music_id from music_likes where user_id = 1)) t
ON m.id = t.music_id
order by id;
可能写得很乱很杂,日后再联系的时候再来改进