SELECT Visits.KHA_ID, tblKentuckyCounties.countyName, tblHospitals.HospitalName, hospitalCounties.countyName
FROM (HospitalType INNER JOIN (hospitalCounties
INNER JOIN
tblHospitals ON hospitalCounties.countyID = tblHospitals.countyFK) ON HospitalType.HospitalTypeID = tblHospitals.HospitalTypeFK)
INNER JOIN
(tblKentuckyCounties INNER JOIN Visits ON tblKentuckyCounties.countyID = Visits.PAT_COUN)
ON tblHospitals.Hosp_ID = Visits.HospitalID;
This is a query that will return the county a patient is from, and the hospital in which they were seen. Works fine. However, how does one make it so that the only returned results are where the counties are different? I assume this is where the 'where' keyword would be used?
Assuming ...
... add a WHERE clause ...
WHERE tblKentuckyCounties.countyName <> hospitalCounties.countyName