2

Is there anyway in xquery to do like in sql: "SELECT name AS buyer"?

enter code here
let $stars := doc("stars.xml")
for $s in $stars/Stars/star
where $s/Address/Street eq "123 Maple St."
return $s/(Name **AS buyer** |cost)

output something like:
<Buyers>
<buyer name=”Ash”><cost>40</cost></buyer>
...
</Buyers>
ZedORYasuo
  • 183
  • 7

1 Answers1

4

Instead of return $s/(Name **AS buyer** |cost), I think you want e.g. return <buyer Name="{$s/Name}">{$s/cost}</buyer>.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110