문제

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