Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001062

[PHP-DB] Re: MySQL: alphabetizing, skipping "the ", "a " From: Cameron Metcalf (cmetcalf <email protected>)
Date: 06/25/01

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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>