Long-time reader, first-time poster here.
I\'m trying to figure out how to sort a list of artists for a music app I\'m writing.
To help understand the databa
This will put all the artists who's names begin with a letter in a-z before those that don't:
SELECT DISTINCT artist
FROM songs
ORDER BY artist REGEXP '^[a-z]' DESC, artist
See it working online: sqlfiddle
But you might prefer to store a second column with the simplified name so that you can put them in an order that makes more sense:
artists
artist | simplified_name
------------------------------------
&i | i
+NURSE | nurse
2007excalibur2007 | excalibur
The values for simplified_name cannot be easily generated in MySQL, so you may want to use a general purpose programming language to pull out all the artists, transform them to simplified names, then populate the database with the results.
Once this is done, you can use this query:
SELECT DISTINCT artist
FROM artists
ORDER BY simplified_name