query-2f6224febbe52ab03829f53c7d1c20fd
Multiple optionals, or filter, must have English label
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?s ?sLabel ?fatherLabel ?motherLabel WHERE {
?s wdt:P31/wdt:P279* wd:Q726 .
OPTIONAL {
?s wdt:P22 ?father
}
OPTIONAL {
?s wdt:P25 ?mother
}
OPTIONAL {
?s wdt:P3165 ?dummy
}
FILTER ( !bound(?dummy) ) .
FILTER (bound(?father) || bound(?mother) ) .
FILTER(EXISTS {
?s rdfs:label ?lang_label.
FILTER(LANG(?lang_label) = "en")
})
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?sLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?dummy")
v4("?father")
v2("?lang_label")
v5("?mother")
v3("?s"):::projected
v1("?sLabel"):::projected
a1((" "))
c10(["bd:serviceParam"]):::iri
c1(["en"]):::literal
c5(["wd:Q726"]):::iri
f0[[" "]]
subgraph f0e0["Exists Clause"]
e0f0[["?lang_label = 'en'"]]
e0f0 --> e0v1
e0v2 --"rdfs:label"--> e0v1
e0v1("?lang_label"):::projected
e0v2("?s"):::projected
end
f0--EXISTS--> f0e0
f0 --> v2
f0 --> v3
f0 --> c2
f1[["?lang_label = 'en'"]]
f1 --> v2
v3 --"rdfs:label"--> v2
f2[["(bound(?father) || bound(?mother))"]]
f2 --> v4
f2 --> v5
f3[["not bound(?dummy)"]]
f3 --> v6
v3 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P22".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P25".-> v5
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P3165".-> v6
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c1
end