query-14754b503abbec371cb1c09cb762ec52
Jurisdictions with shared borders - query optimization?) from among a set of jurisdictions which I have in a separate database. (P47)shares border with I have the following simple query which works well enough for me so far. I am trying to find jurisdictions that share a border (
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?a ?b WHERE {
VALUES ?a { wd:Q172 wd:Q44013 wd:Q44198 }
VALUES ?b { wd:Q172 wd:Q44013 wd:Q44198 }
?a wdt:P47 ?b.
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?a"):::projected
v2("?b"):::projected
bind0[/VALUES ?a/]
bind0-->v1
bind00(["wd:Q172"])
bind00 --> bind0
bind01(["wd:Q44013"])
bind01 --> bind0
bind02(["wd:Q44198"])
bind02 --> bind0
bind1[/VALUES ?b/]
bind1-->v2
bind10(["wd:Q172"])
bind10 --> bind1
bind11(["wd:Q44013"])
bind11 --> bind1
bind12(["wd:Q44198"])
bind12 --> bind1
v1 --"wdt:P47"--> v2