Re: How to do this in Mckoi
Chas Douglass <[email protected]>
| Newsgroups | gmane.comp.db.mckoi |
|---|---|
| Message-ID | <[email protected]> |
Kevin Schmidt wrote: > Why won't a query that simply just joins the three tables work? > Something like: > > SELECT Patient.name, Patient.birthDate, count(*) AS num_medications > FROM Patient join Medications on Patient.id = Medications.patientId join > Diseases on Patient.id = Diseases.patientId > WHERE Diseases.disease = 'x' > GROUP BY Patient.name, Patient.birthDate > > Kevin > Thanks so much for your help. I tried this and got no results. So I changed the join on the Medications table to a LEFT OUTER JOIN (isn't that right when Medications might not have any matches?), which gets back rows, but they all list "num_medications" as 1, even though they are actually different. This, of course, isn't exactly my schema, so I had to make some other changes which I believe are not relevant. Chas Douglass --------------------------------------------------------------- Mckoi SQL Database mailing list http://www.mckoi.com/database/ To unsubscribe, send a message to [email protected]