Following sparql query will give the persons who are dead.

select distinct ?item{
?item <http://freebase.com/ns/common/topic/notable_types> <http://freebase.com/ns/people/person> .
?item <http://freebase.com/ns/people/deceased_person/date_of_death> ?y .
}

I want to get all the persons who are alive. How to express this in SPARQL syntax? Its more like asking, get me all the nodes which doesn't have a specific edge. Is it possible in SPARQL?

Thanks in Advance. Any help is appreciated.

有帮助吗?

解决方案 2

Sure. You can use this construction:

SELECT DISTINCT ?item {
    ?item <http://freebase.com/ns/common/topic/notable_types> <http://freebase.com/ns/people/person> .
    OPTIONAL {?item <http://freebase.com/ns/people/deceased_person/date_of_death> ?y}
    FILTER (!BOUND(?y))
}

其他提示

In SPARQL 1.1

SELECT DISTINCT ?item {
    ?item <http://freebase.com/ns/common/topic/notable_types> <http://freebase.com/ns/people/person> .
    FILTER NOT EXISTS { ?item <http://freebase.com/ns/people/deceased_person/date_of_death> ?y}
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top