下面的SQL查询需要合并,以便进一步减少结果。其中一个需要是一个子查询。我是Access的新手,我只是得到错误。最终结果应进一步过滤结果,以仅显示满足两个查询中所有条件的遭遇。这两个结果都能得到正确的结果......非常感谢您提供的任何帮助。
SELECT encounter.encounter_id,medications.encounter_id,medications.medication_id,medication_types.medication_id,medication_types.name,medication_types.class FROM medication_types INNER JOIN(遭遇INNER JOIN药物遇到.encounter_id = medications.encounter_id)ON药物_types.medication_id = medications.medication_id drug_types.class LIKE' 抗生素';
SELECT encounter.encounter_id,encounter.admit_year,diseases.encounter_id,diseases.disease_id,disease_types.disease_id,disease_types.icd9cm 从遇到 INNER JOIN(disease_types INNER JOIN disease ON disease_types.disease_id = diseases.disease_id)ON encounter.encounter_iD = diseases.encounter_id 在哪里疾病_types.icd9cm IN(' 041.3',' 480.0',' 480.1',' 480.2',' 480.3'' 480.8'' 480.9'' 481'' 482.1',' 482.2 '' 482.9'' 486'' V03.82'' V12.61') 和admit_week BETWEEN 5和9 AND encounter.admit_year = 2014 ORDER BY encounterters.admit_week;
答案 0 :(得分:0)
如果您不需要显示药物和疾病,只需返回相遇信息,请考虑:
SELECT DISTINCT encounters.encounter_id, admit_year FROM Query2 WHERE encounters.encounter_id IN (SELECT encounters.encounter_id FROM Query1);