基本的に、特定のクエリ結果を外部キーのエントリの列で並べ替えたいと考えています。ここに私が持っているテーブルがあります:
class
------
classId
profId    //Points to a profId from professor table
courseId  //Points to a specific courseId from course table
semId     //Points to a specific semId from semester table
professor
---------
profId
first   //first name
last    //last name
course
------
courseId
department //The `CMSC` in CMSC101
number    //The `101` in CMSC101
title    
semester
--------
semId
season  //example: Spring, Summer, Fall
year
それらを階層的に並べ替えたいだけでなく、クラス列の列の外部キーによっても並べたいと思います。したがって、SELECTすべてのエントリを次のclass順序で並べ替えます。
- コース→学科
 - コース→番号
 - コース→セクション
 - 教授 -> 最後
 - 教授→最初
 - 学期 -> 年
 - 学期 -> シーズン