I have a table called a medicine and a related subcategory called Medication_symptoms
Medicine
MediId, Name 1, MedA 2, MedB 3, MedC
Medication_symptoms
MedSympId, Medicine (MedId), Symptom (symptomId) 1, MedA (1), Symptom A (1) 2, MedA (1), Symptom B (2) 3, MedB (2), Symptom B (2) 4, MedB (2), Symptom C (3) 5, MedC (3), Symptom D
I have another table called Patient and Patient_Symptoms
A patient
PatientId, Name 1, Patient A 2, Patient B 3, Patient C 4, Patient D
Patient_Symptom
PatientSymptomId, PatientId, SymptomId 1, Patient A(1), Symptom A (1) 2, Patient A(1), Symptom B (2) 3, Patient B(2), Symptom B (2) 4, Patient B(2), Symptom D (4) 5, Patient D(4), Symptom D (4)
Given the above information, I need to get a medicine that matches all the symptoms of the patient: (I would pull information to each patient 1 on 1)
Patient A - Med A (as he has symptom a and b and Med is for symptom A and B) Patient B - None! (as he has symptoms b and d and there is no medicine for symptoms B and D) Patient D - Med C (as med C is for symptom D only and Patient D has only symptom D)
Note Symptoms - separate table:
Symptom
Symptom Id, Name 1, Symptom A 2, Symptom B 3, Symptom C 4, Symptom D 5, Symptom E
What is a request?
Note. I made this example. In what I do, I have an A record with a set of attributes (where the attributes are stored as rows of records against the A record). I need to map this entry A to another entry C, which has the same set of attributes as A. (Making sense?)
You can create tables and some sample data using a script at http://pastebin.com/kaqdtHf3