RE: Sorting table columns dynamically on normalized MySQL tables

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

 



[snip]
Doing a join on four tables is ok? (serious question, not being
facetious).
[/snip]

Yes, it is OK. Make sure that you have the tables properly indexed and
you'll have no problems.

[snip]
R> By definition, in SQL, if you don't specify a sort order (or in
R> this case a second order) then the SQL engine can and will output
R> the records in any order it feels like.

Really? I didn't know that. I thought it started at record 0 and then
output them in the order they appeared in the table data view (using
something like PHPMyAdmin.)
[/snip]

PHPMyAdmin uses an ORDER BY clause and it is initially on the primary
key index for any given table. Then PHPMyAdmin uses relevant column data
for the sort. SQL CAN and DOES spit out the records any way it wants
when no sort is specified. You dod not typically see it because of query
caching. (Ever notice that a second issue of the same query you just
made is much faster? Query caching.)

[snip]
R> If you *DELETE* an ID number, then put another one in, but force it
R> to be the same ID number you'll probably see the records come out
R> in a different order. It's usually a really Bad Idea to do that
R> (forcing an ID to be re-used) but for the purposes of
R> learning/demonstration you can do it.

I'll give it a shot sometime to see. It'll be interesting to find out.
[/snip]

+1 on the bad idea for primary key re-use.

[snip]
If they sort by location, they want the course records to show up in
alphabetical order based on location. Right now it does sort by
location, but it's not alphabetical because the Course.locationID,
Course.instructorID, and Course.categoryID are integers which relate
to three other respective tables. There is no join, and I didn't think
you were "supposed" to do a join on four tables.
[/snip]

Furthering our discussion of the ORDER BY clause...you can put more than
one sort criteria there...

ORDER BY l.locationName, c.courseName

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