我有兩個表:Mysql的最大查詢
teachers (teacher_id,teacher_name)
courses (teacher_id,course_id)
,我需要顯示的老師的名字,教學課程的最大數量:
的mysql>選擇teachers.teacher_name,tmp1.teacher_id,TMP1 .cnt from(選擇max(tm p.cnt)as tmpMax from(選擇teacher_id,count(teacher_id)as cnt from course g groups by teacher_id)as tmp)as tmp2,(選擇teacher_id,count(teacher_id)as cnt from course group by teacher_id)as tmp1,teachers where tmp1.cnt = tmp2.tmpMax and teac hers.teacher_id = tmp1.teacher_id;
我想出了上述查詢。有沒有更簡單的查詢這個問題?
錯誤1054(42S22):'where子句'中的未知列'course_count' – dharm0us 2009-04-19 05:59:41