Re: Sorting table columns dynamically on normalized MySQL tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxx> 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
> 
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux