RE: [PHP] Sorting table columns dynamically on normalized MySQL tables
| From: | Jay Blanchard | Date: | Tue, 19 Apr 2005 19:28:25 +0000 |
| Subject: | RE: [PHP] Sorting table columns dynamically on normalized MySQL tables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-213404@lists.php.net to get a copy of this message | ||
[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