query-ea53e6c35a36ccdcc6446a556d95484a
List of all partnerships in the district of OffenbachI‘d like to get a query that return a list of all twinning partnerships of all levels of contained administrative territories of: District of Offenbach Q7912 contains administrative territorial entity P150 twinned administrative body P190 The problem that I see, is that the P150 can contain further P150 and that P190 can appear in all of these levels... 10:35, 19 February 2020 (UTC)) talk (Dichter—: You use property paths when something can happen at multiple levels in a hierarcy. In this case the * after wdt:P150 menaing 0 or more recursions of the property:Dichter@
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?twin ?twinLabel
WHERE
{
wd:Q7912 wdt:P150* ?item.
?item wdt:P190 ?twin.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?item"):::projected
v2("?twin"):::projected
c5(["bd:serviceParam"]):::iri
c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c1(["wd:Q7912"]):::iri
c1 --"wdt:P150"--> v1
v1 --"wdt:P190"--> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end