需要帮助使用 join 方法和 concat 方法将 sql 中的三个 table 连接起来
Need help joining three table in sql using join method and concat method
有如下三个table,其中最后一个table由前两个table的两列组成:
V:
我用 where 子句完成了问题,但无法用 join 方法完成。
在这里,我使用了 where 子句:
SELECT appointmentdate,doctorname,concat(name,' ',family) AS patientname
from appointment,doctor,patients
WHERE doctor.doctor_id=appointment.doctor_id
AND appointment.patient_id=patients.patient_id;
SELECT a.appointmentdate,
d.doctorname,
p.patientname
FROM appointment a
JOIN doctors d
ON a.doctor_id = d.doctor_id
JOIN patients p
ON a.patient_id = p.patient_id;
有如下三个table,其中最后一个table由前两个table的两列组成:
V:
我用 where 子句完成了问题,但无法用 join 方法完成。 在这里,我使用了 where 子句:
SELECT appointmentdate,doctorname,concat(name,' ',family) AS patientname
from appointment,doctor,patients
WHERE doctor.doctor_id=appointment.doctor_id
AND appointment.patient_id=patients.patient_id;
SELECT a.appointmentdate,
d.doctorname,
p.patientname
FROM appointment a
JOIN doctors d
ON a.doctor_id = d.doctor_id
JOIN patients p
ON a.patient_id = p.patient_id;