I need to return cno and the zip
x in customers/customer
z in customers/customer/city
return {data($x/@cno)}
{$z/zipcode}
It returns every cno, I need zip code that matches cno
<customers>
<customer cno="2222">
<city>
<zip>67226</zip>
<phone>316-636-5555</phone>
</city>
</customer>
<customer cno="1000">
<city>
<zip>67226-1555</zip>
<phone>000-000-0000</phone>
</city>
</customer>
</customers>
The following query returns the result you describe:
xquery version "3.1";
for $customer in /customers/customer
return
$customer/@cno || ": " || $customer/city/zip
The result:
2222: 67226
1000: 67226-1555
Complete sample code can be found at http://xqueryfiddle.liberty-development.net/jyyiVhv .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.