query-a0348fad9b6431a2ed74dec97177ae86
Example with horses/optionalsOptionals can affect total number of results:
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 ?book ?title ?illustratorLabel ?publisherLabel ?published
WHERE
{
?book wdt:P50 wd:Q35610. # 138
OPTIONAL { ?book wdt:P1476 ?title. } # 2 Q25713842
OPTIONAL { ?book wdt:P110 ?illustrator. } # 0
OPTIONAL { ?book wdt:P123 ?publisher. } # 2 Q2297190
OPTIONAL { ?book wdt:P577 ?published. } # 0
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;
v1("?book"):::projected
v3("?illustrator")
v5("?published"):::projected
v4("?publisher")
v2("?title"):::projected
c8(["bd:serviceParam"]):::iri
c10(["en"]):::literal
c2(["wd:Q35610"]):::iri
v1 --"wdt:P50"--> c2
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P1476".-> v2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P110".-> v3
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P123".-> v4
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P577".-> v5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end