SPARQL Examples

From Semantic Lab
Revision as of 01:09, 25 February 2025 by Matt (talk | contribs)
Jump to navigation Jump to search

All -- records

All records associated with our various projects on Wikibase


 # All records associated with our various projects on Wikibase

SELECT DISTINCT ?item ?itemLabel ?type ?typeLabel ?project ?projectLabel WHERE {
    ?item wdt:P1 ?type.
    ?item wdt:P11 ?project.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  
}
ORDER BY ?projectLabel

All -- person records

 #All person records associated with our projects on Wikibase

SELECT ?person ?personLabel ?project ?projectLabel
WHERE 
{
  ?person  wdt:P1 wd:Q1.
  ?person wdt:P11 ?project.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

ORDER BY ?projectLabel

All -- city records

 #All city records associated with our projects on Wikibase

SELECT ?city ?cityLabel WHERE {
  ?city wdt:P1 wd:Q19058.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

All -- Sponsored by

Show all the entities that have the property P155 ("sponsored by") claim with the value, what the item is and who they are sponsored by


 #Show all the entities that have the property P155 ("sponsored by") claim with the value, what the item is and who they are sponsored by
SELECT ?item ?itemLabel ?sponsored_by ?sponsored_byLabel ?instance_of ?instance_ofLabel ?part_of_project ?part_of_projectLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P155 ?sponsored_by. }
  OPTIONAL { ?item wdt:P1 ?instance_of. }
  OPTIONAL { ?item wdt:P11 ?part_of_project. }
}