query-31019f18639623f0a319637c96087df8

rq turtle/ttl

Propertiesinstance of (P31)shares border with (P47)

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?nqid ("P47" as ?P47) ?qid 
WHERE {
?item wdt:P31 wd:Q262166.
?item wdt:P47 ?neighbor.
 SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". }
FILTER(NOT EXISTS { ?neighbor wdt:P47 ?item. }).
BIND(SUBSTR(STR(?item), STRLEN(STR(wd:)) + 1) AS ?qid).
BIND(SUBSTR(STR(?neighbor), STRLEN(STR(wd:)) + 1) AS ?nqid)
}
ORDER BY xsd:integer(REPLACE(?nqid,"Q",""))

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?P47") v3("?item") v2("?neighbor") v5("?nqid"):::projected v4("?qid"):::projected c7(["bd:serviceParam"]):::iri c5(["wd:Q262166"]):::iri c9(["de,en"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P47"--> e0v2 e0v2("?item"):::projected e0v1("?neighbor"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c3 f0 --> v3 v2 --"wdt:P47"--> v3 v3 --"wdt:P31"--> c5 v3 --"wdt:P47"--> v2 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end bind1[/"substring(str(?item),string-length(str('wd:')) + '1^^xsd:integer')"/] v3 --o bind1 bind1 --as--o v4 bind2[/"substring(str(?neighbor),string-length(str('wd:')) + '1^^xsd:integer')"/] v2 --o bind2 bind2 --as--o v5 bind3[/"'P47'"/] bind3 --as--o v5