query-7f61c95cd6f2af079804d735d5ca129d
.on Mastodon and on TwitterOriginally posted
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?subject ?subjectLabel ?outerPartLabel ?innerPartLabel ?outerHasPartInner WHERE {
?subject p:P527 [
ps:P527 ?outerPart;
pq:P527 ?innerPart
].
BIND(EXISTS { ?outerPart wdt:P527 ?innerPart. } AS ?outerHasPartInner)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?subjectLabel ?outerPartLabel ?innerPartLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?innerPart")
v3("?innerPartLabel"):::projected
v7("?outerHasPartInner"):::projected
v4("?outerPart")
v2("?outerPartLabel"):::projected
v6("?subject"):::projected
v1("?subjectLabel"):::projected
a1((" "))
c5(["bd:serviceParam"]):::iri
c7(["#91;AUTO_LANGUAGE#93;,en"]):::literal
a1 --"p:statement/P527"--> v4
a1 --"p:qualifier/P527"--> v5
v6 --"p:P527"--> a1
v4 --"p:direct/P527"--> v5
bind0[/" "/]
subgraph bind0e0["Exists Clause"]
e0v1 --"p:direct/P527"--> e0v2
e0v2("?innerPart"):::projected
e0v1("?outerPart"):::projected
end
bind0--EXISTS--> bind0e0
v4 --o bind0
null --o bind0
v5 --o bind0
bind0 --as--o v7
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end