I have created the following query:
SELECT PatientProfile.searchname as PatientName
, PatientProfile.Birthdate as DOB
, DoctorFacility.OrgName
, Appointments.ApptStart
, Appointments.ApptStop
, ApptType.Name
FROM PatientProfile left JOIN
DoctorFacility ON PatientProfile.DoctorId = DoctorFacility.DoctorFacilityId
AND PatientProfile.FacilityId = DoctorFacility.DoctorFacilityId
AND PatientProfile.PrimaryCareDoctorId = DoctorFacility.DoctorFacilityId
AND PatientProfile.RefDoctorId = DoctorFacility.DoctorFacilityId
right JOIN
Appointments ON DoctorFacility.DoctorFacilityId = Appointments.DoctorId
AND DoctorFacility.DoctorFacilityId = Appointments.FacilityId
AND DoctorFacility.DoctorFacilityId = Appointments.ResourceId
right JOIN
ApptType ON Appointments.ApptTypeId = ApptType.ApptTypeId
where appttype.Name like 'sbx%' or appttype.Name like 'obot%'
I am able to return the following results from columns ApptStart, ApptStop, Name, however patientname, patientbirthdate, and location do not contain any data which I also need. Since I am new to creating queries on multiple tables I am quite sure I am writing (linking) something wrong. Would appreciate any help offered.