How to use Let Clause with XQuery in XML

In this article we will discuss about what is Let Clause in XQuery and how it will be used in XQuery.
  • 4736

This Clause is used in FLWOR Expression of XQuery. This Clause is optional means this is not mandatory to use it. This Clause is used to assign a value to the variable and avoids iteration means it avoids the repeation execution of the same expression many times. This is the following example to use it.

let $m := (1 to 10)
return <result>{$m}</result>

In the above statement we have seen that through the Let Clause 1 to 10 values have been assigned to the variable m have been returned. The output will be as follows:

<result>1 2 3 4 5 6 7 8 9 10</result>

In the above output it is clear that iteration of the same statement has been avoided and as a result the value of the variable .i.e. $m is coming in one line means together.

If we want we can use the multiple let clause at one place. Lets have a look on the following example.

           let $m : = 2
           let $n  : = "Hello"
           let $s  : = $m+1
                  <n> {$n }</n>,
                  <s>  {$s} </s>



Ask Your Question

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.