RE: Sorting table columns dynamically on normalized MySQL tables [LONG]

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

 



[snip]
SELECT *
FROM Course
ORDER BY locationID ASC

Now the ORDER BY can be any one of five things based on the variable
passed by the hyperlink for the column they clicked on (location,
course, date, category, and instructor
[/snip]

If you had a JOIN to the location table you could order by the actual
location. Here is an example...

SELECT c.courseName, l.locationName
FROM Course c, Location l
WHERE c.locationID = l.locationID
ORDER BY l.locationName

[snip]
Sorry that this has degenerated into a MySQL question rather than PHP.
I was originally looking for how people handled it in PHP.
[/snip]

Actually it didn't degenerate, it was a SQL question all along. Unless
you had a desire to build sortable arrays in PHP this type of sort
should always be done on the SQL side because it would be much more
efficient.

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