Jump to content

Archived

This topic is now archived and is closed to further replies.

skeezmo

Distinct Substring Query

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.