SQL-Instant Request Feature

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Instant Request Feature

SQL Query

#Instant Request Feature


SET @req_artist := (SELECT `songs`.`artist` FROM `songs`
LEFT JOIN `queuelist` ON `songs`.`artist` = `queuelist`.`artist`
#OPTIONAL Adjust Artist Repeat Rules by Replacing $ArtistRepeatInterval$ With a Number of
Minutes
WHERE `songs`.`id_subcat` = 171 AND (TIMESTAMPDIFF(MINUTE, `songs`.`artist_played`,
NOW()) > $ArtistRepeatInterval$)
AND `queuelist`.`artist` IS NULL
ORDER BY `songs`.`date_played` ASC LIMIT 1);
#Feature Opener
SELECT id, title, artist FROM (
SELECT `songs`.`id`, `songs`.`title`, `songs`.`artist` FROM `songs`
WHERE `songs`.`id` = 3266
LIMIT 1
) AS open
UNION ALL
#Request VO
SELECT id, title, artist FROM (
SELECT `songs`.`id`, `songs`.`title`, `songs`.`artist` FROM `songs`
WHERE `songs`.`id_subcat` = 171 AND `songs`.`artist` = @req_artist
ORDER BY `songs`.`date_played` ASC
LIMIT 1
) AS vo
UNION ALL
#Station ID Jingle
SELECT id, title, artist FROM (
SELECT `songs`.`id`, `songs`.`title`, `songs`.`artist` FROM `songs`
WHERE `songs`.`id` = 3266
LIMIT 1
) AS jingle
UNION ALL
#Song Request
SELECT id, title, artist FROM (
SELECT DISTINCT `songs`.`id`, `songs`.`title`, `songs`.`artist` FROM `songs`
LEFT JOIN `queuelist` ON `songs`.`artist` = `queuelist`.`artist`
WHERE`songs`.`enabled` = 1
AND `songs`.`song_type` = 0 AND `songs`.`id_genre` IN ('143','118','70') AND
`songs`.`id_subcat` = 2 AND `songs`.`artist` = @req_artist
#OPTIONAL Adjust Artist Repeat Rules to Match Number of Minutes Above
AND ((TIMESTAMPDIFF(MINUTE, `songs`.`date_played`, NOW()) > $TrackRepeatInterval$)
AND (TIMESTAMPDIFF(MINUTE, `songs`.`artist_played`, NOW()) > $ArtistRepeatInterval$))
AND `queuelist`.`artist` IS NULL
ORDER BY `songs`.`date_played` ASC
LIMIT 1
) AS song;

______________

CUSTOMIZATION

You need to change the following to match your database values:


-‘id_subcat’
-’id_genre’
-`songs`.`id`

For more questions, please re-watch the video tutorial:


https://youtu.be/aam00nst_aA

Have fun! BUT, for real 80s fun, tune-in to XXX80s.com!

Courtesy of RadioDJ Dude


https://www.youtube.com/@RadioDJDude

You might also like