Project:SPARQL/examples: Difference between revisions

From KBTestWikibase
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
=== Cats ===
=== Cats ===
{{SPARQL|query=SELECT ?item ?itemLabel
<sparql tryit="1">
WHERE  
PREFIX bd: <http://www.bigdata.com/rdf#>
{
PREFIX wikibase: <http://wikiba.se/ontology#>
   ?item wdt:P31 wd:Q146. # Must be of a cat
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } #Helps get the label in your language, if not, then en language
PREFIX p: <https://kbtestwikibase.wikibase.cloud/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 
SELECT ?p ?pLabel ?pDescription ?pAltLabel ?w WHERE {
  ?p rdf:type wikibase:Property.
   OPTIONAL{?p wdt:P1 ?w.}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
}}
ORDER BY ASC(xsd:integer(STRAFTER(STR(?p), 'P')))
</sparql>

Revision as of 17:18, 29 June 2022

Cats

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
PREFIX p: <https://kbtestwikibase.wikibase.cloud/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?p ?pLabel ?pDescription ?pAltLabel ?w WHERE {
  ?p rdf:type wikibase:Property.
  OPTIONAL{?p wdt:P1 ?w.} 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ASC(xsd:integer(STRAFTER(STR(?p), 'P')))

Try it!