ZedORYasuo
ZedORYasuo

Reputation: 175

Equivalent to AS in XQuery?

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>

Upvotes: 2

Views: 37

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167571

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

Upvotes: 4

Related Questions