1、原句子:
SELECT * FROM tbl_time_table WHERE course_id in (SELECT course_id FROM tbl_student_course where student_id={$student_id})
2、优化后:
SELECT t.* FROM tbl_time_table AS t JOIN (SELECT DISTINCT course_id FROM tbl_student_course where student_id={$student_id}) AS s ON t.course_id=s.course_id
网上搜到的,我只看了那个贴子的最后一楼,呵呵。不过expain优化后的句子,看不明白是什么意思。