Re: Sorting table columns dynamically on normalized MySQL tables

From: Date: Wed, 20 Apr 2005 00:44:58 +0000
Subject: Re: Sorting table columns dynamically on normalized MySQL tables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-213441@lists.php.net to get a copy of this message
Greetings, If you are still looking for "tips" and want to get complicated/fancy, I have seen columns used called sort_order more than a few times. This should not be too hard to maintain for things like a few buildings, etc., where the lookup table does not change much over time. You would then have another option for your "oder by" clause. cheers, KB On 4/19/05, Jay Blanchard <jay.blanchard@niicommunications.com> wrote: > [snip] > I can do that, but is there a better way? How do you all handle > dynamic sorting of normalized DBs? > [/snip] > > Normalization has no effect on sort order where any DB is concerned. > Sort order is determined in the sort clause in the query. So if you want > to sort by location and you are using MySQL your ORDER BY clause should > be location....(regardless of joins) > > SELECT foo > FROM bar > ORDER BY location > > returns > > course instructor location > Science Bill Elementary School > Basket Weaving Dave High School > Math Dave Middle School > Biology Jessica Middle School > > The results with course as the sort qualifier > > course instructor location > Basket Weaving Dave High School > Biology Jessica Middle School > Math Dave Middle School > Science Bill Elementary School > > You have over-compicated a simple issue > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#213441) next »