skeezmo Posted July 31, 2006 Share Posted July 31, 2006 Hello,I have a large list of songs and artists and I am creating a playlist. At the top, I have the user select a letter which will then direct them to artists that start with that letter.The problem I am running into is for artists that start with a number should be going under a separate category [b]0-9 and '[/b]. But instead they are going as individual numbers in the list.The query I am running for this is: [code]SELECT distinct substr(artist, 1,1) as browse FROM songlist WHERE songtype = "S" or songtype = "C" ORDER by artist asc[/code]I have tried adding into the where clause AND songlist.browse not like '1%') etc.My question is, can I run a query and exclude numbers from returning in the result?Does anyone have any suggestions that I could use to accomplish this?Thank you in advance to anyone who may be of help.Hess Smith Link to comment https://forums.phpfreaks.com/topic/16062-distinct-substring-query/ Share on other sites More sharing options...
fenway Posted August 2, 2006 Share Posted August 2, 2006 You should probably be able to use a regex and exlude the appropriate character class (UNTESTED):[code]SELECT distinct substr(artist, 1,1) as browse FROM songlist WHERE songtype = "S" or songtype = "C" AND LEFT(artist,1) REGEXP "^[0-9']" ORDER by artist asc[/code] Link to comment https://forums.phpfreaks.com/topic/16062-distinct-substring-query/#findComment-67805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.