query-e98e1f0f76ce171f1c3c8e2d6dc6034d
– anything where some sort of “fallback” makes sense. (P1843)taxon common name , and (P1786)posthumous name , (P1449)nickname Other properties that may be used in this way include clause for “member of some moon mission” and another one for “member of Apollo 13”. But we only want to select those results where at least one of those conditions is true. OPTIONAL (close enough, right?). That restriction can’t be expressed as a single property path, so we need one (Q182252)Apollo 13 blocks has been fulfilled. For example, let’s get all astronauts that went to the moon, as well as the members of OPTIONAL to ensure that at least one of several FILTER with BOUNDYou can also combine
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 ?astronaut ?astronautLabel
WHERE
{
?astronaut wdt:P31 wd:Q5;
wdt:P106 wd:Q11631.
OPTIONAL {
?astronaut wdt:P450 ?mission.
?mission wdt:P31 wd:Q495307.
}
OPTIONAL {
?astronaut wdt:P450 wd:Q182252.
BIND(wd:Q182252 AS ?mission).
}
FILTER(BOUND(?mission)).
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?astronaut"):::projected
v3("?mission")
c7(["wd:Q182252"]):::iri
c9(["bd:serviceParam"]):::iri
c2(["wd:Q5"]):::iri
c11(["en"]):::literal
c4(["wd:Q11631"]):::iri
c6(["wd:Q495307"]):::iri
f0[["bound(?mission)"]]
f0 --> v3
v2 --"wdt:P31"--> c2
v2 --"wdt:P106"--> c4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P450".-> v3
v3 --"wdt:P31"--> c6
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P450".-> c7
bind1[/"'wd:Q182252'"/]
bind1 --as--o v3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end