TNeykov
TNeykov

Reputation: 73

SPARQL query for all sameAs

I want to take all objects with the relation owl:sameAs with my object Berlin.

Upvotes: 0

Views: 2765

Answers (1)

ccjmne
ccjmne

Reputation: 9618

It's actually quite simple:

PREFIX owl:<http://www.w3.org/2002/07/owl#>

SELECT ?obj WHERE {
    dbpedia:Berlin (owl:sameAs|^owl:sameAs)* ?obj
}

How it works: This is going to select all ?obj for which there is any triple such as:

subject           predicate     object
dbpedia:Berlin    owl:sameAs    ?obj

or:

subject           predicate     object
?obj              owl:sameAs    dbpedia:Berlin

Upvotes: 5

Related Questions