# [openEHR SEC] AQL FROM & CONTAINS with many entries **Category:** [Technical (archive)](https://discourse.openehr.org/c/technical-archive/156) **Created:** 2017-10-01 15:52 UTC **Views:** 1 **Replies:** 6 **URL:** https://discourse.openehr.org/t/openehr-sec-aql-from-contains-with-many-entries/15498 --- ## Post #1 by @system Hi all, another question about AQL and CONTAINS. Most of the AQL samples use just one branch in the FROM clause, like: EHR CONTAINS COMPOSITION CONTAINS OBSERVATION. I'm wondering what would be the correct FROM notation when more than one ENTRY is needed. Some examples below. SELECT o1/data[...]/.../value, o2/..., .... FROM COMPOSITION c [archid] CONTAINS OBSERVATION o1 [archid2], COMPOSITION c [archid] CONTAINS OBSERVATION o2 [archid3], COMPOSITION c [archid] CONTAINS OBSERVATION o3 [archid4] WHERE ... SELECT o1/data[...]/.../value, o2/..., .... FROM COMPOSITION c [archid] CONTAINS OBSERVATION o1 [archid2] AND CONTAINS OBSERVATION o2 [archid3] AND CONTAINS OBSERVATION o3 [archid4] WHERE ... Thanks! --- ## Post #2 by @system Hi Pablo, I hope I understood correctly: select a_a/data[at0002]/events[at0003]/data[at0001]/items[at0004]/value, a_b/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value from EHR e contains COMPOSITION a contains ( OBSERVATION a_a[openEHR-EHR-OBSERVATION.body_temperature.v1] and OBSERVATION a_b[openEHR-EHR-OBSERVATION.blood_pressure.v1]) this should be the right way to express the query. I think an account for EHRSCAPE could be of help if you want to dig deeper into AQL. Cheers, Birger --- ## Post #3 by @Seref X contains (y and z and t) The paranthesis are optional above but would help avoid ambiguity when we have X contains y and z contains t and o Is it: X contains y and (z contains t) and o Or X contains y and (z contains t and o) ?? As you can see the paranthesis help define the containment structure --- ## Post #4 by @Seref Also see this, just in case it may help clarify relevant Qs: [https://github.com/serefarikan/aql-discussion](https://github.com/serefarikan/aql-discussion) --- ## Post #5 by @system Thanks, my goal besides understanding the syntax is to improve the current spec, so I'm testing some use cases against the AQL spec instead of using specific implementations. Cheers, Pablo. --- ## Post #6 by @system gotcha, makes sense, I need to check the grammar in the specs to see where parenthesis can be used. --- ## Post #7 by @system OK, makes sense! Please excuse me for stating the obvious :) Birger --- **Canonical:** https://discourse.openehr.org/t/openehr-sec-aql-from-contains-with-many-entries/15498 **Original content:** https://discourse.openehr.org/t/openehr-sec-aql-from-contains-with-many-entries/15498