How can I do this in MSS-Access sql?

I have 2 table with a common key. tblPatient and tblMeds linked by chart. Is there a way in sql to get all the patients that have (for example) MedicationA, MedicationB and MedicationC? I want all the patients that take all 3 medications. Sounds simple but it dosn't seem to be. Thanks in advance.
Who is Participating?
aikimarkConnect With a Mentor Commented:
sure.  with the query wizard, join the tblPatient and tblMeds tables.

Add the patient identifying field to the grid.
Add the med identifying field to the grid twice.
Click the summation toolbar button, converting this to a Group By query.
Change the first Med column type to Count.
Change the second Med column type to Where
In the criteria for the second Med column, type an In ( , , ) condition that will select all three meds you are interested in.

Test this query to make sure you've got the In() clause typed correctly.

Go back to design mode.
In the criteria area for the first Med column, type 3.

Run the query again.
Jeffrey CoachmanMIS LiasonCommented:
Then why not post what you tried, so we can look at it...?
You have tblPatients and tblMeds.  You need a third table tblPatsMeds containing the Meds taken by each patient.  In this case, you want to know which patients in tblPatsMeds has a record for each of meds MedA, MedB, and MedC.

FROM tblPatsMeds
PIVOT MedID IN ("MedA","MedB","MedC")

Once you see that this works, you can get additional details like FName, LName, MedName by Joining to tblPatients and tblMeds.
DevLSSAuthor Commented:
Thanks, that does it!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.