A where clause with multiple expressions : where « XQuery « XML






A where clause with multiple expressions


File: Data.xml


<order>
  <car model="A">
    <id>0001</id>
    <name language="en">name 1</name>
  </car>
  <car model="B">
    <id>0002</id>
    <name language="en">name 2</name>
  </car>
  <car model="B">
    <id>0003</id>
    <name language="en">name 3</name>
  </car>
  <car model="C">
    <id>0004</id>
    <name language="en">name 4</name>
  </car>
</order>


File: Query.xquery

for $prod in doc("Data.xml")//car
let $prodmodel := $prod/@model
where $prod/id > 100
      and starts-with($prod/name, "F")
      and exists($prod/colorChoices)
      and ($prodmodel = "B" or $prodmodel = "A")
return $prod

 








Related examples in the same category

1.where with or operator
2.Embedding the where clause