XQuery:将一个值与多个值进行比较,例如 SQL“in”命令

发布于 2024-09-24 07:19:18 字数 102 浏览 1 评论 0原文

因此,如果某个值包含在其他一些值中,我需要将一个值与多个其他值进行比较(查询会产生多个元素)。在 SQL 中,有“IN”运算符来实现这一点,但是 XQuery 呢? 感谢您的任何提示:-)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

窗影残 2024-10-01 07:19:18

XQuery = 运算符的行为与您所描述的完全一样:

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

true

eq 运算符是用于比较单个值的版本。

但是,如果您正在查找节点 $node 是否位于特定的节点列表 $sequence 中,那么您想要

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

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
木落 2024-10-01 07:19:18
let $values := ('1', '2', '3')
for $row in $table
where $row/value = $values
return $row

或者,如果您内联它,您可以这样做:

for $row in $table
where $row/value = ('1', '2', '3')
return $row
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文