query-05e303049fbad16ecdb5e8242d58a891
List of all the comuni in a specific region, Q1210-Lombardia in this example
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 bd: <http://www.bigdata.com/rdf#>
#Italia: Provinces and comuni in a specific region
#defaultView:Table
SELECT ?provincia ?provinciaLabel ?comune ?comuneLabel
WHERE 
{
  ?provincia wdt:P131 wd:Q1210 .                 # Administrative divisions in the region "Lombardia"
  { ?provincia wdt:P31 wd:Q15089 . }             # List of provinces
  UNION
  { ?provincia wdt:P31 wd:Q15110 . }             # metropolitan cities of Italy
  UNION
  { ?provincia wdt:P31 wd:Q21190155 . }          # Liberi consorzi comunali of Sicily
  ?comune wdt:P131 ?provincia .                  # Administrative divisions in the province
  {
    ?comune wdt:P31 wd:Q747074 .                 # Italian municipality
  }
  UNION
  {
    ?comune wdt:P31 wd:Q954172 .                 # Italian sparse municipality
  } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?provinciaLabel ?comuneLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?comune"):::projected 
  v2("?comuneLabel"):::projected 
  v3("?provincia"):::projected 
  v1("?provinciaLabel"):::projected 
  c6(["wd:Q21190155"]):::iri 
  c10(["bd:serviceParam"]):::iri 
  c8(["wd:Q954172"]):::iri 
  c5(["wd:Q15110"]):::iri 
  c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal 
  c2(["wd:Q1210"]):::iri 
  c4(["wd:Q15089"]):::iri 
  c7(["wd:Q747074"]):::iri 
  v3 --"wdt:P131"-->  c2
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    subgraph union1[" Union "]
    subgraph union1l[" "]
      style union1l fill:#abf,stroke-dasharray: 3 3;
      v3 --"wdt:P31"-->  c6
    end
    subgraph union1r[" "]
      style union1r fill:#abf,stroke-dasharray: 3 3;
      v3 --"wdt:P31"-->  c5
    end
    union1r <== or ==> union1l
    end
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v3 --"wdt:P31"-->  c4
  end
  union0r <== or ==> union0l
  end
  v4 --"wdt:P131"-->  v3
  subgraph union2[" Union "]
  subgraph union2l[" "]
    style union2l fill:#abf,stroke-dasharray: 3 3;
    v4 --"wdt:P31"-->  c8
  end
  subgraph union2r[" "]
    style union2r fill:#abf,stroke-dasharray: 3 3;
    v4 --"wdt:P31"-->  c7
  end
  union2r <== or ==> union2l
  end
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c10 --"wikibase:language"-->  c12
  end