query-9e72e0eec88e396b71f0ff01fe072fd1

rq turtle/ttl

Examples and how to useThe templates can be used in conjunction with any template that needs sparql input, or as any over template if you just want to see the result. For example we can write a query of all cats with articles on frwiki whose label starts with an "L" using the three partials |Q146|?cat}}Query instances{{ |?cat|L}}LabelStartsWith{{ |?cat|fr}}Articles in wikipedia{{ template }}Sparql{{all put in a }} } }}fr|L|?cat|LabelStartsWith{{ # whose fr label starts with a capital L }}fr|?cat|articles in wikipedia{{ # with an frwiki article }}Q146|?cat|query instances{{ select ?cat { # cats (Q146 = cat) instances =query|sparql{{which gives

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?cat ?catLabelFr{
  # cats (Q146 = cat) instances
  ?cat wdt:P279*/wdt:P31 wd:Q146 .
  # with an frwiki article 
  ?cat ^schema:about/schema:isPartOf <https://fr.wikipedia.org/> .
  # whose fr label starts with a capital L

     ?cat rdfs:label ?catLabelFr filter (lang(?catLabelFr) = "fr"&& strstarts(?catLabelFr, "L"))
 }

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?cat"):::projected v1("?catLabelFr"):::projected a1((" ")) a2((" ")) c5(["wd:Q146"]):::iri c8([https://fr.wikipedia.org/]):::iri f0[["?catLabelFr = 'fr'starts-with(?catLabelFr,'L')"]] f0 --> v1 v2 --"wdt:P279"--> a1 a1 --"wdt:P31"--> c5 a2 --"schema:about"--> v2 a2 --"schema:isPartOf"--> c8 v2 --"rdfs:label"--> v1