Quantcast
Channel: Squeezebox : Community : Forums - 3rd Party Software
Viewing all articles
Browse latest Browse all 2059

Hoping for help with SQL Playlist

$
0
0
Running LMS 7.9.1 - 1522157629 on Debian 8 X86_64, and I have recently discovered SQL Playlist. I see some references in the forum saying that it does not work well with recent versions of LMS. So far it is working well for me, but I am struggling to get it to do some things.

I do not know SQL, nor am I familiar with the structure of the LMS database. I have general experience with relational databases and Boolean expressions. Following some basic online guides to SQL, I have tried to apply those concepts. So far, nothing has worked.

Specifically, I want to make use of multiple genre tags. For instance, I have many files with the genre tag, 'Jazz'. Some of those files also have a genre tag that says 'Xmas'. (There are many more files that have the 'Xmas' genre tag, along with some other genre, and a few that only have the 'Xmas' tag.)

My goal is to set up a playlist that only plays files that have both 'Jazz' and 'Xmas' tags. All attempts so far have failed miserably.

Here's the code generated by SQL Playlist for a playlist that plays only 'Jazz':

Code:

-- PlaylistName:Random temp
-- PlaylistGroups:
select tracks.url from tracks
        join genre_track on
                tracks.id=genre_track.track
        join genres on
                genre_track.genre=genres.id
        left join dynamicplaylist_history on
                tracks.id=dynamicplaylist_history.id and dynamicplaylist_history.client='PlaylistPlayer'
        where
                audio=1
                and dynamicplaylist_history.id is null
                and genres.name in ('Jazz')
        group by tracks.id
        order by random()
        limit 10;

So far, I have attempted to another line to the 'where' section, like so:

Code:

and (genres.name in ('Jazz')
and genres.name in ('Xmas'))

I have tried different groupings of parentheses, without success.

I also tried doubling the 'where' section:

Code:

                (audio=1
                and dynamicplaylist_history.id is null
                and genres.name in ('Jazz')
                and (audio=1
                and dynamicplaylist_history.id is null
                and genres.name in ('Xmas')))

Again, no luck with several variations on that format.

Is what I'm trying to do possible? If anyone is willing to share some hints about the right way to do it, I will be very grateful!

Viewing all articles
Browse latest Browse all 2059

Trending Articles