query-eea700b3065cfe581ecadf4860d4073c
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
SELECT ?item ?category ?commonsCategory WHERE {
?item wdt:P373 ?commonsCategory .
?commonsSitelink schema:about ?item; schema:isPartOf <https://commons.wikimedia.org/>; schema:name ?sitelink_label .
FILTER(STRSTARTS(STR(?commonsSitelink), "https://commons.wikimedia.org/wiki/Category")) . # sitelink to a category
BIND(str(substr(?sitelink_label,10)) as ?category) . # strip "Category:" part
FILTER( false = (?category = ?commonsCategory) ).
VALUES ?item {
wd:Q6672
wd:Q37920
}.
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?category"):::projected
v2("?commonsCategory"):::projected
v3("?commonsSitelink")
v6("?item"):::projected
v5("?sitelink_label")
c6([https://commons.wikimedia.org/]):::iri
f0[["'false^^xsd:boolean' = ?category = ?commonsCategory"]]
f0 --> v6
f0 --> v2
f1[["starts-with(str(?commonsSitelink),'https://commons.wikimedia.org/wiki/Category')"]]
f1 --> v3
v6 --"wdt:P373"--> v2
v3 --"schema:about"--> v6
v3 --"schema:isPartOf"--> c6
v3 --"schema:name"--> v5
bind2[/"str(substring(?sitelink_label,'10^^xsd:integer'))"/]
v5 --o bind2
bind2 --as--o v6
bind3[/VALUES ?item/]
bind3-->v6
bind30(["wd:Q6672"])
bind30 --> bind3
bind31(["wd:Q37920"])
bind31 --> bind3