So I have an XQuery that looks something like this:
for $i in /*:rootElement
where $i/*:field = "test"
return $i
This query returns a lot of results, but I only really need one. How can I return just the first item in the result sequence?
So I have an XQuery that looks something like this:
for $i in /*:rootElement
where $i/*:field = "test"
return $i
This query returns a lot of results, but I only really need one. How can I return just the first item in the result sequence?
(for $i in /*:rootElement where $i/*:field = "test" return $i)[1]
On a side note, a better way to write this is to use step predicates:
/*:rootElement[*:field = "test"][1]