fizzjob wrote:Is there a better method of checking for an empty string? Should I be looking for "is null" instead?
The mentioned method with <Multi Artist> <> '' is the best, it is simplest and probably fastest (since its query tests less records then <Artist> <> ''). For example, let say that I have only one track in the database where Artist = "David Bowie;Queen". That Artist field is actually the MM Artist field, but in MN it is one record with <Multi Artist> = "David Bowie;Queen" and two records with <Artist> = "David Bowie" and <Artist> = "Queen".
You cannot use <Artist> IS NULL condition because the corresponding queries in MN never return <Artist> as null. Magic Nodes uses INNER JOIN with multi-item fields, for example here is the query for selected node with Filter:<Artist> IS NULL:
Code: Select all
SELECT * FROM Songs WHERE Songs.ID IN (SELECT Songs.ID FROM Songs, ArtistsSongs AS AArtistsSongs, Artists AS SongArtists WHERE (SongArtists.Artist IS NULL) AND Songs.ID = AArtistsSongs.IDSong AND AArtistsSongs.IDArtist = SongArtists.ID AND (AArtistsSongs.PersonType = 1 OR AArtistsSongs.PersonType IS NULL))
By the way, in SQLite "FROM Songs, AArtistsSongs WHERE Songs.ID = AArtistsSongs.IDSong" is same as "FROM Songs INNER JOIN AArtistsSongs ON Songs.ID = AArtistsSongs.IDSong".
You see, such query with INNER JOIN never returns records where SongArtists.Artist IS NULL. That condition could be used only with LEFT JOIN query, for example:
Code: Select all
SELECT * FROM Songs WHERE Songs.ID IN (SELECT Songs.ID FROM Songs LEFT JOIN ArtistsSongs AS AArtistsSongs ON Songs.ID = AArtistsSongs.IDSong LEFT JOIN Artists AS SongArtists ON AArtistsSongs.IDArtist = SongArtists.ID AND (AArtistsSongs.PersonType = 1 OR AArtistsSongs.PersonType IS NULL) WHERE (SongArtists.Artist IS NULL))
However, LEFT JOINs are horribly slower then INNER JOINs in SQLite used in MM3, so I decided not to use them. It seems that the speed of LEFT JOINs is drastically improved in the new SQLite used in MM4, but I don't want to change anything regarding to that because of the compatibility. I have implemented another way to display empty (unknown) values for multi-item fields anyway.
fizzjob wrote:I sent you a PM with a link to my database.
Thanks for the database. However, even with it I am getting the correct results with your mask with the same number of tracks (2272), not matter where the node is positioned (inside of the Magic Nodes folder, inside of the Playlists folder...). Here is the fixed mask with the node in the Playlist folder:
Code: Select all
Duck And Cover|Child of:Playlists|Position:Child|Filter:<Artist> <> <Original artist> and <Artist> <> '' and <Folder> not Like 'd:\Christmas%'\<Title|Sort order:Random|Show nodes:no>