query-36cc5c5077279dd5fefe7baeda5589af
List all items that have a named after (P138) naming locality (Q22815296) SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE { ?item wdt:P138 wd:Q22815296; wdt:P138 ?namedAfterItem . OPTIONAL { ?namedAfterItem rdfs:label ?namedAfterItemLabel . FILTER(LANG(?namedAfterItemLabel) = 'en') . } SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } } GROUP BY ?item ?itemLabel
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# List all items that have a named after (P138) naming locality (Q22815296)
SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE {
?item wdt:P138 wd:Q22815296; wdt:P138 ?namedAfterItem .
OPTIONAL {
?namedAfterItem rdfs:label ?namedAfterItemLabel .
FILTER(LANG(?namedAfterItemLabel) = 'en') .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?item"):::projected
v4("?namedAfter")
v3("?namedAfterItem")
v1("?namedAfterItemLabel"):::projected
c6(["bd:serviceParam"]):::iri
c3(["wd:Q22815296"]):::iri
c1(["en"]):::literal
v2 --"wdt:P138"--> c3
v2 --"wdt:P138"--> v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."rdfs:label".-> v1
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c1
end
bind1[/"?namedAfterItemLabel"/]
v1 --o bind1
bind1 --as--o v4