Question

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.

Was it helpful?

Solution 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))
}

OTHER TIPS

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}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top