Hi
Im certanly no expert at SQL and I was wondering if some one could help me out with a query.
Here is a simplified description of the issue:
I have three tables one is Patient another is Medication and the Last is MedicationChange...
Patient
=======================================
Patient_id(PK) Name Address
=======================================
Medication
=====================================================
Medication_id(PK) Patient_id(FK) Medication
=====================================================
MedicationChange
========================================================
MedicationChange_id(PK) Medication_id(FK) Reason
Dose Dose_Date
========================================================
They are all related together. The relationship is expressed as 1 Patient to many Medications and 1 Medication to many MedicationChanges.
What I wish to extract from the data is any Patient that is on a certain Medication eg:antibiotics AND is on another Medication eg:steriods but has two MedicationChange records related with it both stating the Reason for change is 'Illergic reaction'.
I realise that a query & subquery (Using IN) will get any patient on two medications but im having trouble in trying to express that the second medication must have two related MedicationChange records that both state in reason field 'Illergic reaction'.
Thanks in advance for anyone that can point me in the right direction
Im certanly no expert at SQL and I was wondering if some one could help me out with a query.
Here is a simplified description of the issue:
I have three tables one is Patient another is Medication and the Last is MedicationChange...
Patient
=======================================
Patient_id(PK) Name Address
=======================================
Medication
=====================================================
Medication_id(PK) Patient_id(FK) Medication
=====================================================
MedicationChange
========================================================
MedicationChange_id(PK) Medication_id(FK) Reason
Dose Dose_Date
========================================================
They are all related together. The relationship is expressed as 1 Patient to many Medications and 1 Medication to many MedicationChanges.
What I wish to extract from the data is any Patient that is on a certain Medication eg:antibiotics AND is on another Medication eg:steriods but has two MedicationChange records related with it both stating the Reason for change is 'Illergic reaction'.
I realise that a query & subquery (Using IN) will get any patient on two medications but im having trouble in trying to express that the second medication must have two related MedicationChange records that both state in reason field 'Illergic reaction'.
Thanks in advance for anyone that can point me in the right direction