query-daab8b2ed32538a5303a2ae62ba12a2b
Run that query. As I’m writing this, it only returns two results – a bit meager! Why is that? We found over a hundred books earlier! The reason is that to match this query, a potential result (a book) must match all the triples we listed: it must have a title, and an illustrator, and a publisher, and a publication date. If it has some of those properties, but not all of them, it won’t match. And that’s not what we want in this case: we primarily want a list of all the books – if additional data is available, we’d like to include it, but we don’t want that to limit our list of results. : optionalThe solution is to tell WDQS that those triples are
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 <span lang="en" dir="ltr" class="mw-content-ltr">?book ?title ?illustratorLabel ?publisherLabel ?published</span>
WHERE
{
?książka wdt:P50 wd:Q35610.
OPTIONAL { ?książka wdt:P1476 ?tytuł. }
OPTIONAL { ?książka wdt:P110 ?ilustrator. }
OPTIONAL { ?książka wdt:P123 ?wydawca. }
OPTIONAL { ?książka wdt:P577 ?opublikowane. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}