• Welcome to RadioDJ - Free Radio Automation Software Forum. Please log in or sign up.

Fast random select!

Started by Everterstraat, January 15, 2018, 10:31:14 PM

Everterstraat

Hi,

Not sure if it's the right subcat of this forum but how about this;


SELECT `ID`, `artist` FROM `songs`
WHERE
LEFT(`artist`, 1) NOT IN (SELECT LEFT(`artist`, 1) FROM `queuelist`)
AND `enabled`=1
AND `song_type`=0
AND ((`start_date` <= Now()) AND (`end_date` >= NOW() OR `end_date` = '2002-01-01 00:00:01'))
AND ((TIMESTAMPDIFF(MINUTE, `date_played`, NOW()) > $TrackRepeatInterval$) AND (TIMESTAMPDIFF(MINUTE, `artist_played`, NOW()) > $ArtistRepeatInterval$))
ORDER BY `date_played` ASC
LIMIT 1;


Fast selection, not already in queue, unique first letter to avoid..

Bruno Mars - title
Blake Shelton - title
Brett Young
Babe Rexa

..but get..

Bruno Mars - title
Ed Shereen - title
Taylor Swift - title
Sam Smith - title

..for example and with honoring the least played time between artists/tracks! Heavy enough?

Is it just good or are there better solutions?