query-ca197a9f1c9e41d1803ad4ab7ea0262e
title:Property replacement for QuickStatements SELECT (CONCAT("-",?itemId,",","P301",",",?valProp,",,",?itemId,",","P971",",",?valProp) as ?command) WHERE { ?item wdt:P971 wd:Q15079786 . ?item wdt:P301 ?val . ?val wdt:P31 wd:Q5 . BIND(REPLACE(STR(?item), "http://www.wikidata.org/entity/","") AS ?itemId) BIND(REPLACE(STR(?val), "http://www.wikidata.org/entity/","") AS ?valProp) }
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#title:Property replacement for QuickStatements
SELECT (CONCAT("-",?itemId,",","P301",",",?valProp,",,",?itemId,",","P971",",",?valProp) as ?command)
WHERE {
?item wdt:P971 wd:Q15079786 .
?item wdt:P301 ?val .
?val wdt:P31 wd:Q5 .
BIND(REPLACE(STR(?item), "http://www.wikidata.org/entity/","") AS ?itemId)
BIND(REPLACE(STR(?val), "http://www.wikidata.org/entity/","") AS ?valProp)
}
Query found at
- https://www.wikidata.org/wiki/User:Ep%C3%ACdosis/Queries
- https://www.wikidata.org/wiki/User:Ep%C3%ACdosis/sandbox
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?command")
v1("?item")
v3("?itemId"):::projected
v2("?val")
v4("?valProp"):::projected
c5(["wd:Q5"]):::iri
c2(["wd:Q15079786"]):::iri
v1 --"wdt:P971"--> c2
v1 --"wdt:P301"--> v2
v2 --"wdt:P31"--> c5
bind0[/"replace(str(?item),'http://www.wikidata.org/entity/','')"/]
v1 --o bind0
bind0 --as--o v3
bind1[/"replace(str(?val),'http://www.wikidata.org/entity/','')"/]
v2 --o bind1
bind1 --as--o v4
bind2[/"concat('-',?itemId,',','P301',',',?valProp,',,',?itemId,',','P971',',',?valProp)"/]
v3 --o bind2
v4 --o bind2
bind2 --as--o v5