有三個MySQL表: 要加入所有三個表,我們需要的是的PK,加上courseid指數: alter table enrollment add index (courseid);
查詢: select s.name, c.name, e.semesterid
from student s
join enrollment e on s.id=e.studentid
join course c
查詢在具有1100萬行的大型表上執行。在查詢執行之前,我已經在表上執行了ANALYZE。 查詢1: SELECT *
FROM accounts t1
LEFT OUTER JOIN accounts t2
ON (t1.account_no = t2.account_no
AND t1.effective_date < t2.effective_date)
WHERE