cuneyttyler
cuneyttyler

Reputation: 1355

SPARQL "any" relationship filter

I want to retrieve entities with any relation to some other entity. Consider following query:

SELECT ?item ?itemLabel 
WHERE 
{
  ?item wdt:P31 wd:Q28598684. 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
# Helps get the label in your language, if not, then en language
}

Here, I would like to have 'wdt:P31' to be any relationship and I want to return this relationship as well. Is that possible?

Upvotes: 1

Views: 44

Answers (1)

Evgeny
Evgeny

Reputation: 3274

As said in comments by the author of the question: you can simply use a variable in the place of the relationship to get the relationship.

select ?item ?property ?itemLabel ?propertyLabel {
  ?item ?property wd:Q28598684. 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
}

Upvotes: 1

Related Questions