编写将仅列出ONCE的Physician-Person约会的SQL代码

时间:2016-03-30 20:58:50

标签: sql sql-server

这个令我困惑?

有三张桌子。 Appointments(Appointment_ID, Physician_ID and Person_ID)Physician(Physician_ID)Person(Person_ID and Physician_ID)

这是我到目前为止所做的:

SELECT DISTINCT Appointment_date_time FROM Appointment 
INNER JOIN Person 
        ON Appointment.Person_ID = Person.Person_ID
INNER JOIN Physician 
        ON Physician.Physician_ID = Person.Physician_ID
HAVING COUNT(*) < 1

1 个答案:

答案 0 :(得分:0)

  

有三张桌子。约会(Appointment_ID,Physician_ID和Person_ID),Physician(Physician_ID)和Person(Person_ID和Physician_ID)。

select *
from Appointments a
inner join Person p
on a.Person_ID = p.Person_ID
inner join Physician ph
on a.Physician_ID = ph.Physician_ID