query-9841a79d8d715d2c887f3836e61b1033

rq turtle/ttl

Finding all organizations in a geographical area (how to fix a query) their municipality and their county in the P131 field. The county values have since been removed from most of the organizations, leaving only the municipalities but not the county. My question is now, how do I change the below search to fix it so that it shows the organizations located in these counties, if we're not allowed to actually list the counties on the organizations' items? bothHi folks! I previously had a search for all the cultural heritage organizations in a geographic area in Georgia, searching by county (see below). This query worked because I had (incorrectly) tagged all of the organizations with

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 DISTINCT ?organization ?organizationLabel ?street_address ?coordinate_location ?phone_number ?e_mail_address ?website ?Facebook_ID ?Twitter_username ?county WHERE {
  VALUES (?located_in_the_administrative_territorial_entity ?county) {
    (wd:Q486843 "Bleckley County")
    (wd:Q498301 "Pulaski County")
    (wd:Q486791 "Wilcox County")
    (wd:Q115272 "Dodge County")
    (wd:Q691614 "Telfair County")
    (wd:Q498332 "Wheeler County")
    (wd:Q493125 "Montgomery County")
    (wd:Q376822 "Toombs County")
    (wd:Q505310 "Tattnall County")
    (wd:Q111867 "Ben Hill County")
    (wd:Q492057 "Irwin County")
    (wd:Q156503 "Coffee County")
    (wd:Q493071 "Jeff Davis County")
    (wd:Q488186 "Appling County")
    (wd:Q488219 "Bacon County")
    (wd:Q488868 "Berrien County")
    (wd:Q488194 "Atkinson County")
    (wd:Q498353 "Ware County")
    (wd:Q492070 "Lanier County")
    (wd:Q493029 "Echols County")
    (wd:Q486167 "Clinch County")
  }
  VALUES ?instance_of {
    wd:Q473972
    wd:Q3152824
    wd:Q210272
    wd:Q570116
    wd:Q57660343
    wd:Q2668072
    wd:Q188913
    wd:Q15243209
    wd:Q2867476
    wd:Q635719
    wd:Q7840289
    wd:Q42998
    wd:Q41710
    wd:Q51369558
  }
  FILTER(NOT EXISTS { ?organization wdt:P576 _:b15. })
  ?organization (wdt:P31/(wdt:P279*)) ?instance_of;
    wdt:P131 ?located_in_the_administrative_territorial_entity.

  OPTIONAL { ?organization wdt:P6375 ?street_address. }
  OPTIONAL { ?organization wdt:P625 ?coordinate_location. }
  OPTIONAL { ?organization wdt:P1329 ?phone_number. }
  OPTIONAL { ?organization wdt:P968 ?e_mail_address. }
  OPTIONAL { ?organization wdt:P856 ?website. }
  OPTIONAL { ?organization wdt:P2013 ?Facebook_ID. }
  OPTIONAL { ?organization wdt:P2002 ?Twitter_username. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  OPTIONAL {  }
}
ORDER BY (?organization)
LIMIT 10000

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?Facebook_ID"):::projected v11("?Twitter_username"):::projected v6("?coordinate_location"):::projected v3("?county"):::projected v8("?e_mail_address"):::projected v4("?instance_of") v2("?located_in_the_administrative_territorial_entity") v1("?organization"):::projected v7("?phone_number"):::projected v5("?street_address"):::projected v9("?website"):::projected a1((" ")) a2((" ")) c15(["en"]):::literal c13(["bd:serviceParam"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P576"--> e0a1 e0v1("?organization"):::projected e0a1((" ")):::projected end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> a1 v1 --"wdt:P576"--> a1 bind1[/VALUES ?county ?located_in_the_administrative_territorial_entity/] bind1-->v2 bind1-->v3 bind10(["wd:Q486843"]) bind10 --> bind1 bind11(["Bleckley County"]) bind11 --> bind1 bind12(["wd:Q498301"]) bind12 --> bind1 bind13(["Pulaski County"]) bind13 --> bind1 bind14(["wd:Q486791"]) bind14 --> bind1 bind15(["Wilcox County"]) bind15 --> bind1 bind16(["wd:Q115272"]) bind16 --> bind1 bind17(["Dodge County"]) bind17 --> bind1 bind18(["wd:Q691614"]) bind18 --> bind1 bind19(["Telfair County"]) bind19 --> bind1 bind110(["wd:Q498332"]) bind110 --> bind1 bind111(["Wheeler County"]) bind111 --> bind1 bind112(["wd:Q493125"]) bind112 --> bind1 bind113(["Montgomery County"]) bind113 --> bind1 bind114(["wd:Q376822"]) bind114 --> bind1 bind115(["Toombs County"]) bind115 --> bind1 bind116(["wd:Q505310"]) bind116 --> bind1 bind117(["Tattnall County"]) bind117 --> bind1 bind118(["wd:Q111867"]) bind118 --> bind1 bind119(["Ben Hill County"]) bind119 --> bind1 bind120(["wd:Q492057"]) bind120 --> bind1 bind121(["Irwin County"]) bind121 --> bind1 bind122(["wd:Q156503"]) bind122 --> bind1 bind123(["Coffee County"]) bind123 --> bind1 bind124(["wd:Q493071"]) bind124 --> bind1 bind125(["Jeff Davis County"]) bind125 --> bind1 bind126(["wd:Q488186"]) bind126 --> bind1 bind127(["Appling County"]) bind127 --> bind1 bind128(["wd:Q488219"]) bind128 --> bind1 bind129(["Bacon County"]) bind129 --> bind1 bind130(["wd:Q488868"]) bind130 --> bind1 bind131(["Berrien County"]) bind131 --> bind1 bind132(["wd:Q488194"]) bind132 --> bind1 bind133(["Atkinson County"]) bind133 --> bind1 bind134(["wd:Q498353"]) bind134 --> bind1 bind135(["Ware County"]) bind135 --> bind1 bind136(["wd:Q492070"]) bind136 --> bind1 bind137(["Lanier County"]) bind137 --> bind1 bind138(["wd:Q493029"]) bind138 --> bind1 bind139(["Echols County"]) bind139 --> bind1 bind140(["wd:Q486167"]) bind140 --> bind1 bind141(["Clinch County"]) bind141 --> bind1 bind2[/VALUES ?instance_of/] bind2-->v4 bind20(["wd:Q473972"]) bind20 --> bind2 bind21(["wd:Q3152824"]) bind21 --> bind2 bind22(["wd:Q210272"]) bind22 --> bind2 bind23(["wd:Q570116"]) bind23 --> bind2 bind24(["wd:Q57660343"]) bind24 --> bind2 bind25(["wd:Q2668072"]) bind25 --> bind2 bind26(["wd:Q188913"]) bind26 --> bind2 bind27(["wd:Q15243209"]) bind27 --> bind2 bind28(["wd:Q2867476"]) bind28 --> bind2 bind29(["wd:Q635719"]) bind29 --> bind2 bind210(["wd:Q7840289"]) bind210 --> bind2 bind211(["wd:Q42998"]) bind211 --> bind2 bind212(["wd:Q41710"]) bind212 --> bind2 bind213(["wd:Q51369558"]) bind213 --> bind2 v1 --"wdt:P31"--> a2 a2 --"wdt:P279"--> v4 v1 --"wdt:P131"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P6375".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P625".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1329".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P968".-> v8 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P856".-> v9 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P2013".-> v10 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P2002".-> v11 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; end