PDA

View Full Version : SQL Skip specific album



evroekel
2008-03-22, 03:37
I'm using this query to get an Italian Playlist but I want to skip some particular albums with the album name 'Sentimento' and 'Viaggio Italiano'.

I can't find the right query or string in the forum. Could you give me a little help?

Thanks in Advance!



-- PlaylistName:Italian
-- PlaylistGroups:
-- PlaylistStartAction1:cli:customskip setsecondaryfilter nosintnoxmas.cs.xml
-- PlaylistStopAction1:cli:customskip clearsecondaryfilter
select tracks.url from tracks
join contributor_track on
tracks.id=contributor_track.track
join contributors on
contributor_track.contributor=contributors.id and contributor_track.role in (1,5)
left join dynamicplaylist_history on
tracks.id=dynamicplaylist_history.id
where
audio=1
and dynamicplaylist_history.id is null
and contributors.name in ('Andrea Bocelli','Eros Ramazotti','Paolo Conte','Laura Pausini')
and *** WHAT TO INSERT HERE?*** NOT in ('Sentimento', 'Viaggio Italiano')
order by rand()
limit 25;

erland
2008-03-23, 01:02
Try something like this, note that you will also need to add both the albums join and the where directive for albums.title



-- PlaylistName:Italian
-- PlaylistGroups:
-- PlaylistStartAction1:cli:customskip setsecondaryfilter nosintnoxmas.cs.xml
-- PlaylistStopAction1:cli:customskip clearsecondaryfilter
select tracks.url from tracks
join contributor_track on
tracks.id=contributor_track.track
join contributors on
contributor_track.contributor=contributors.id and contributor_track.role in (1,5)
join albums on
albums.id=tracks.id
left join dynamicplaylist_history on
tracks.id=dynamicplaylist_history.id
where
audio=1
and dynamicplaylist_history.id is null
and contributors.name in ('Andrea Bocelli','Eros Ramazotti','Paolo Conte','Laura Pausini')
and albums.title NOT in ('Sentimento', 'Viaggio Italiano')
order by rand()
limit 25;

erland
2008-03-24, 20:57
Sorry, there was a small bug in the previous one, this should do it:


-- PlaylistName:Italian
-- PlaylistGroups:
-- PlaylistStartAction1:cli:customskip setsecondaryfilter nosintnoxmas.cs.xml
-- PlaylistStopAction1:cli:customskip clearsecondaryfilter
select tracks.url from tracks
join contributor_track on
tracks.id=contributor_track.track
join contributors on
contributor_track.contributor=contributors.id and contributor_track.role in (1,5)
join albums on
albums.id=tracks.album
left join dynamicplaylist_history on
tracks.id=dynamicplaylist_history.id
where
audio=1
and dynamicplaylist_history.id is null
and contributors.name in ('Andrea Bocelli','Eros Ramazotti','Paolo Conte','Laura Pausini')
and albums.title NOT in ('Sentimento', 'Viaggio Italiano')
order by rand()
limit 25;