在SPARQL查询中指定具有多个值的交点

编程入门 行业动态 更新时间:2024-10-24 14:19:35
本文介绍了在SPARQL查询中指定具有多个值的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试建立一个查询,该查询返回具有两个命名参与者的事件.这些参与者的姓名是使用名字和姓氏的值指定的. 到目前为止,这是我能够提出的唯一可行的解​​决方案:

I'm trying to build a query that returns events that have two named participants. The names of these participants are specified using values for the first name and last name. So far, this is the only working solution I have been able to come up with:

SELECT ?event WHERE { ?event con:hasParticipant ?personA . ?personA con:hasFirstName "Bob"^^xsd:string . ?personA con:hasLastName "Smith"^^xsd:string . ?event con:hasParticipant ?personB . ?personB con:hasFirstName "The"^^xsd:string . ?personB con:hasLastName "Bear"^^xsd:string . }

...但是我想知道是否有更好的方法?

...but I'm wondering if there is a better way of doing this?

任何帮助将不胜感激!

推荐答案

这几乎与缩小SPARQL查询,但在此条件中要寻找的人有更多特定条件(在另一条件中,任务是找到参与者,主持人或荣誉客人).那里的答案会有所帮助.在这种情况下,您可以使其更简单.您可以使用逗号分隔多个对象(例如,?event hasParticipant?p1,?p2 ).您可以使用空白节点来避免为人员绑定变量,并且可以(可能)消除字符串上的数据类型:

This is almost identical to Narrowing down on SPARQL query, except that there are more specific conditions on who you're looking for in this one (in the other one, the task was to find participants, moderators, or guests of honor). The answer there will help. In this case, you can make this a bit simpler. You can separate multiple objects with commas (e.g., ?event hasParticipant ?p1, ?p2). You can use blank nodes to avoid binding variables for the people, and you can (probably) eliminate the datatypes on the strings:

SELECT ?event { ?event con:hasParticipant [ con:hasFirstName "Bob" ; con:hasLastName "Smith" ] , [ con:hasFirstName "The" ; con:hasLastName "Bear" ] . }

更多推荐

在SPARQL查询中指定具有多个值的交点

本文发布于:2023-10-28 19:46:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537599.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   交点   SPARQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!