I have three tables that are in ManyToMany relationship. 1.playlist 2.tracks 3.playlist_tracks
I want to retrieve 10 playlist with limit of 5 songs. how can i do it? I have tried with this way..
select t1.id as playlistId, t2.playlist_id as pivot_playlist_id, t2.track_id as track_id
from playlist t1
join playlist_tracks t2 on t1.id = t2.playlist_id
left join (
select t3.id as track_id , t3.is_published
from tracks t3
where t3.is_published = 1
group by t3.id limit 5
) xx on t2.track_id = xx.track_id
where t1.prior != 0 AND t1.is_published = 1 ;
but don't get proper result, as it is not applying limit on tracks. It returns all the songs of particular playlist. Where I am doing wrong> Please help me.Here is the DBfiddle for the same sqlfiddle.com/#!9/feddbd/1