XQuery and FLWOR
Added 26 Jul 2008
for should look familiar. Here's the brief rundown on what FLWOR clauses do:-
for: You can use
forto take a node set and iterate over it. In many ways,foris the assignment of a variable to the current value in a node set, so you can operate on that variable. -
let: You assign values to variable with
let, although (as you'll soon see) you won't useletas often as you use the other FLWOR clauses. -
where:
wherelets you apply selection criteria to a node set, beyond what XPath offers. Of course, in many queries, you'll see thatwhereisn't doing more than XPath; it's just moving the predicate on an XPath to a different place. -
order by: The
order byclause doesn't change data, or filter it; it just applies an ordering to a result set, and allows you to sort values based on something other than the location used in the XPath itself. -
return: Using a
returnclause lets you operate on a node set, but then return (in results) something other than that node set. You might want to select a set, order and filter it, and then return only the child elements of the results;returnis the key that makes that possible.