Various SQL rotation examples.


The Rules:


Force rules and sweepers place.


One track on genre name
SELECT s.ID
FROM songs s
INNER JOIN genre g ON s.id_genre = g.id
WHERE g.name = 'Acapella'
ORDER BY RAND()
LIMIT 1;

1 rotation between between bpm 10-50
-- Query rotation limit to 2 tracks between 20 to 51 bpm
SELECT ID, artist, title FROM songs WHERE $ForceRepeatRules$  AND bpm >='10' AND bpm <'51' ORDER BY rand() LIMIT 2 ;




1 track between 20 to 51 bpm from id_subcat and least played.
-- Query rotation limit to 1 track between 20 to 51 bpm from id_subcat and eest played.
SELECT ID, artist, title FROM songs WHERE $ForceRepeatRules$ 
AND bpm >='10' AND bpm <'51'  AND ID_SUBCAT = 30 
AND COUNT_PLAYED = (SELECT MIN(COUNT_PLAYED) FROM SONGS WHERE ID_SUBCAT = 30) ORDER BY RAND() LIMIT 1 ;


Change the ID_SUBCAT number.



ADD 3 TRACKS WITH SWEEPER FROM 1970 TO 1989
/*
ADD 3 TRACKS WITH SWEEPER FROM 1970 TO 1989
*/

SELECT ID, year, path FROM songs WHERE $ForceRepeatRules$ AND year >='1970' and year < '1990' ORDER BY rand() LIMIT 3;
$SweeperOnStart$