テーブルAppointments
、Patients
、およびDoctors
があり、 のすべてのレコードがおよび によっておよびDoctors にAppointments
関連付けられているとします。これら 2 つのクエリの違いは何ですか。それらのいずれかの長所と短所は何ですか:Patients
patient_id
doctor_id
1:
SELECT Patients.first_name,Patients.last_name,Patients.patient_id,
Doctors.first_name, Doctors.last_name,Doctors.doctor_id,
Appointments.app_length,Appointments.app_datetime
FROM Appointments,Patients,Doctors
WHERE Appointments.doctor_id=Doctors.doctor_id
AND Appointments.patient_id=Patients.patient_id
2:
SELECT Patients.first_name,Patients.last_name,Patients.patient_id,
Doctors.first_name, Doctors.last_name,Doctors.doctor_id,
Appointments.app_length,Appointments.app_datetime
FROM Patients INNER JOIN Appointments ON Appointments.patient_id=Patients.patient_id
INNER JOIN Doctors ON Appointments.doctor_id=Doctors.doctor_id
どちらも機能し、同じ結果が得られることを知っておくとよいでしょう。しかし、違いと、どちらが大量のデータに対してより最適化されているかを知りたいです。