开发者

XQuery: Compare one value to multiple values like SQL "in" command

I need to compare one value to multiple other values (a query resulting in more than one element), therefore, if a value is includ开发者_StackOverflow社区ed in some other values. In SQL there's the "IN" operator for that, but what about XQuery? Thanks for any hint :-)


The XQuery = operator behaves exactly as you describe:

3 = (1,2,3,4,5)

is true.

The eq operator is the version for comparing single values.

However if you are looking for whether a node $node is in a particular list of nodes $sequence, then you want

some $x in $sequence satisfies $x is $node


let $values := ('1', '2', '3')
for $row in $table
where $row/value = $values
return $row

Or you could do this if you inlined it:

for $row in $table
where $row/value = ('1', '2', '3')
return $row
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜