I am a novice sql programmer so i need a little help trying to get a query extraction.
I need to get the unique songs played out of a table per week.
Say in a certain week there have been played 8 different songs but those 8 songs have been played numerous times each, i just want the 8 songs to show up.
I need this done by joining 2 tabels, a STATS table and a PLAYLIST table
SELECT playlist.p_title AS title, stats.s_week AS week, playlist.p_artist AS artist, p_id
FROM stats, playlist
WHERE stats.s_pid = playlist.p_id
AND s_uid =31
ORDER BY s_week DESC
LIMIT 0 , 30
This is my original query that gives me all the songs that has been played in all weeks, even if they have been played a number of times in each week, which is what i dont want.
Anyone able to help me distinct the songs per week?
Thanks in advance – Rasmus
1 Answer