0

テーブルAppointmentsPatients、およびDoctorsがあり、 のすべてのレコードがおよび によっておよびDoctors にAppointments関連付けられているとします。これら 2 つのクエリの違いは何ですか。それらのいずれかの長所短所は何ですか:Patientspatient_iddoctor_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

どちらも機能し、同じ結果が得られることを知っておくとよいでしょう。しかし、違いと、どちらが大量のデータに対してより最適化されているかを知りたいです。

4

0 に答える 0