Re: alphabetizing titles when first word begins with 'The','A',etc.

From: Date: Thu, 18 Apr 2002 20:51:47 +0000
Subject: Re: alphabetizing titles when first word begins with 'The','A',etc.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93600@lists.php.net to get a copy of this message
Steph, > Hi. Im using MySQL and as part of my tables I have titles (of stories). > My question os in regards to outputing those titles. Some of the titles > begin with words such as 'The', 'A', 'An', etc. Is there a way to > order > these particular titles based on the second word in the title?? Late reply -- I don't check this folder that often. I had this exact problem. Don't bother with temp tables, or extra fields, or anything like that. You can build it all into your MySQL query. A resident MySQL expert gave me this recipe (well, one very similar): <? $query = 'SELECT title_field, some_other_fields FROM some_table WHERE some_field = 'some_criteria' ORDER BY TRIM(leading "An " from TRIM(leading "A " from TRIM(leading "The " from title_field))) '; ?> No fuss, no muss. You don't have to worry about what order they were inserted in, artificially munging your data, or anything else. HTH! -- [ joel boonstra | jboonstra@gospelcom.net ]

« previous php.general (#93600) next »