FLWOR

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)

The topic of this article may not meet Wikipedia’s general notability guideline. Please help to establish notability by citing reliable secondary sources that are independent of the topic and provide significant coverage of it beyond its mere trivial mention. If notability cannot be established, the article is likely to be merged, redirected, or deleted.
Find sources: ”FLWOR” – news · newspapers · books · scholar · JSTOR · free images (August 2011) (Learn how and when to remove this template message)

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (June 2016) (Learn how and when to remove this template message)

(Learn how and when to remove this template message)

The programming language XQuery defines FLWOR (pronounced ‘flower’) as an expression that supports iteration and binding of variables to intermediate results. FLWOR is an acronym: FOR, LET, WHERE, ORDER BY, RETURN.[1] FLWOR is loosely analogous to SQL’s SELECT-FROM-WHERE and can be used to provide join-like functionality to XML documents.

for creates a sequence of nodes
let binds a sequence to a variable
where filters the nodes on a boolean expression
order by sorts the nodes
return gets evaluated once for every node

Contents

1 Example
2 Example using MS SQL Server
3 References
4 External links

Example[edit]

for $d in doc(“depts.xml”)//deptno
let $e := doc(“emps.xml”)//employee[deptno = $d]
where count($e) >= 10
order by avg($e/salary) descending
return
<big-dept>
{ $d,
<headcount>{count($e)}</headcount>,
<avgsal>{avg($e/salary)}</avgsal>
}
</big-dept>

First column of the XQuery request shows the for, let, where, order by and return keywords of the FLWOR paradigm. In plain English, this could be read as “Get all departments that have more than ten employees, order these departments by decreasing average salary, and return a report of department numbers, head counts and average salary in each big department”. The result could look like:

<big-dept>
<deptno>17</deptno>
<headcount>25</headcount>