Play Music By Advanced SQL Selection

If you know anything about databases, you'll know that you can query them by means of a 'Structured Query Language' (SQL) select statement. If you are fluent in writing SQL, you can use the Play Music menu Option 4 : Play music by advanced SQL selection to construct SQL select statements to pick out music you want to listen to and have Giocoso play the results. If you are not familiar with relational databases and SQL, then I strongly suggest you give this menu option a miss! The word 'advanced' is in there for a reason!!

Giocoso will not hand-hold you at this point: you're expected to know how to construct the WHERE clauses of a SQL query, in a syntactically correct manner for a MySQL (or MariaDB) database.

To give you a hint as to why you might want to get up to speed with this menu option, however, consider this use of the selection filter form (from the Play Music menu Option 2):

It's fairly clear, I think, what the user is trying to do here: I'd like to listen to quartets and/or chamber music by two different British composers. It's a perfectly reasonable request, but Giocoso will respond to it this way:

This is because Giocoso matches each filter with the contents of each metadata tag… so saying 'Composer = Britten or Bridge' means Giocoso is looking for music whose ARTIST tag was literally set to 'Britten or Bridge'… and that's an absurd value to assign to an ARTIST tag! Giocoso is not reading these filters in an intelligent manner, basically: it's treating them as literal text, so only literal matches work.

The same is true for the GENRE tag: you'll probably have tagged your music as either being a 'Quartet' or as being 'Chamber' music, but it's highly unlikely that you'll have tagged any of it with the literal text 'Quartet or Chamber'. If you didn't, then nothing is going to match the filter settings on this screen!

The Giocoso 'standard' selection filter cannot, in other words, do 'or' tests…. which is why you might want to start writing your own SQL which can do so with relative ease. Here, for example, is a selection test that would precisely give accurate results which the filter form was attempting to achieve but could not:

You'll first note that the form displayed only processes the text in a SQL query that comes after the WHERE keyword. I do not need (and in fact must not write!) anything from before that point: Giocoso fills all that in for you. You do not need to say “select * from…” or mention table names, for example. All you have to do is mention composers, genres, performers and other tag-derived information in a SQL WHERE clause in a way that makes logical sense.

Giocoso will also 'sanitise' your input to some extent. If, for example, you use the keywords update or delete or include a semi-colon in your text, those will all be stripped out of your text automatically. If the resulting query results in gibberish, so be it: you'll be told nothing matches your selection criteria. If more than one recording does match the submitted WHERE clause, then you'll be offered a chance to save the matching records in a playlist. If you choose not to, fine: playback of the selections begins immediately. If you do save your playlist, playback begins immediately after the playlist is saved.

Here is the playlist resulting from the Britten/Bridge/Chamber/Quartet query you see me submitting above:

It certainly mentions recordings by the two named composers and in the two genres requested (and no others!): so multiple selections joined with AND and OR keywords, with judicious use of parentheses to constrain processing order along logically-meaningful lines has certainly worked in this case.

Hopefully, you'll now see why the Advanced SQL option exists -but if you aren't familiar with writing SQL, it's a high mountain to climb. I would strongly recommend installing a tool such as DB Browser for SQLite and using its GUI tools to investigate the Giocoso database structure and to practice SQL selections before hoping to use Play Menu option 4 to meaningfully generate the sort of subtle and complex music selections it's capable of, anyway.

A couple of notes to conclude.


| Back to Software Home | Back to Giocoso Documentation Home | Back to Play Music Menu |