SPARQL examples: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
=== Institutions === | === Institutions === | ||
<syntaxhighlight lang="SPARQL" class=" | <syntaxhighlight lang="SPARQL" class="mw-highlight-lang-sparql"> | ||
SELECT ?institution ?institutionLabel | SELECT ?institution ?institutionLabel | ||
WHERE | WHERE | ||
| Line 17: | Line 17: | ||
=== Humans === | === Humans === | ||
<syntaxhighlight lang="SPARQL" class="mw-highlight mw-highlight-lang-sparql mw-content- | <syntaxhighlight lang="SPARQL" class="mw-highlight mw-highlight-lang-sparql mw-content-ltr"> | ||
#Lists all humans with values of selected fields | #Lists all humans with values of selected fields | ||
SELECT ?human ?humanLabel ?fatherLabel ?motherLabel ?date_of_birth WHERE { | SELECT ?human ?humanLabel ?fatherLabel ?motherLabel ?date_of_birth WHERE { | ||
| Line 31: | Line 31: | ||
=== Humans without parents === | === Humans without parents === | ||
<syntaxhighlight lang="SPARQL" class="mw-highlight mw-highlight-lang-sparql mw-content- | <syntaxhighlight lang="SPARQL" class="mw-highlight mw-highlight-lang-sparql mw-content-ltr"> | ||
#Lists all humans without parents | #Lists all humans without parents | ||
SELECT ?human ?humanLabel WHERE { | SELECT ?human ?humanLabel WHERE { | ||
Revision as of 11:47, 12 May 2022
This page is parsed by the web interface of the query service to fill the query example dialog.
Institutions
SELECT ?institution ?institutionLabel
WHERE
{
?institution wdt:P47 wd:Q467. # instance of Institution
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Humans
#Lists all humans with values of selected fields
SELECT ?human ?humanLabel ?fatherLabel ?motherLabel ?date_of_birth WHERE {
?human wdt:P47 wd:Q32.
OPTIONAL { ?human wdt:P66 ?father. }
OPTIONAL { ?human wdt:P68 ?mother. }
OPTIONAL { ?human wdt:P7 ?date_of_birth. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Humans without parents
#Lists all humans without parents
SELECT ?human ?humanLabel WHERE {
?human wdt:P47 wd:Q32. #find humans
MINUS {
?human wdt:P68 [] . # without father
?human wdt:P66 [] . # without mother
?human wdt:P65 [] . # without any unspecified parent
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}