Unfortunately the code doesn't suit my purpose.
But it's doing what you actually asked for.
So this gives me a visual list of all albums which exist in Playlist "Test" and the media library.
Which is the opposite from your original question.
Is there any way to have this fed back into a new Playlist "Result"?
No, this is logically not possible, because only tracks can be added to a playlist, not summarized results like in your query. However you could either remove the tracks from the test playlist, which don't exist in the media library or add the matching tracks to another playlist.
To do this you first need to create another virtual table for the playlists, which allows you to manipulate them:
DROP TABLE IF EXISTS Playlist_Updatable;
CREATE VIRTUAL TABLE Playlist_Updatable USING MetaDB_Module(no_multivalue_split,playlist);
The deleting of the unmatched tracks could be done with (not possible in this case without NOT EXISTS):
DELETE FROM Playlist_Updatable pu
WHERE playlist_name='Test'
AND NOT EXISTS (SELECT 1
FROM ml_tmp
WHERE artist=pu.artist
AND album=pu.album)
If you don't want to list the result it's not necessary to add the columns title and codec to the table ml_tmp and also an index to speed up the lookup on this table should be created. It could look like this:
DROP TABLE IF EXISTS ml_temp;
CREATE TEMPORARY TABLE ml_temp
AS SELECT DISTINCT artist,album
FROM MediaLibrary;
CREATE UNIQUE INDEX ml_temp_in_unique on ml_tmp(artist,album);
Adding the matching tracks to another playlist could look like this (if the target playlist, doesn't exist, i will be automatically created):
INSERT INTO Playlist_Updatable(metadb_handle,playlist_name)
SELECT metadb_handle,'New playlist'
FROM Playlist_Updatable /* or just Playlist, it doesn't matter */ pu JOIN ml_temp ml ON ml.artist=pu.artist AND ml.album=pu.album
WHERE playlist_name='Test'
Note1: I didn't test the SQL statements, so they might be not 100% correct.
Note2: You will run into troubles, if the combination of artist and album is not unique, i.e. you have more than one album with the same combination, but this depends on the content of your media library and your individual tagging guidelines.