Re: MySQL: alphabetizing, skipping "the ", "a "
| From: | Cameron Metcalf | Date: | Mon, 25 Jun 2001 12:43:17 +0000 |
| Subject: | Re: MySQL: alphabetizing, skipping "the ", "a " | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-9811@lists.php.net to get a copy of this message | ||
Hey all,
I'm trying to generate a alphabetized list of items
from my database, but I want to alphabetize the list,
skipping the leading articles in the title for each item.
some solutions suggest creating a 2nd (dummy name) column
to alphabetize by, but I don't want to maintain two columns for
my name field. but I've been using the following to ignore 'the ' and 'a
':
$select = mysql_select_db("bases");
$query = "SELECT IF(left(nameE,2)='A ' or left(nameE,4)='The ',
if(left(nameE,2)='A ',right(nameE,length(nameE)-2),
right(nameE, length(nameE)-4)),nameE) as
alphabet,nameE FROM principle order by alphabet";
$result = mysql_query($query)
but if I want to ignore third or fourth variable, on top of 'the ' and
'a ', what syntax would I use, to include these additional cases in my
script
above?
the above query was built on a coding solution I found at
http://www.bitmechanic.com/mail-archives/mysql/May1998/0713.html
*mysql: select statements that ignore "the "*
Cameron