0

假设我们有表Appointments, Patients, and Doctors, 中的每条记录Appointments都与and和PatientsDoctors相关。这两个查询有什么区别。它们各自的优缺点什么patient_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