query-147d29bb9469b1cc9047db6db1a869b5

rq turtle/ttl

TEMPLATE={ "template": { "en": "Performing arts production 'from' country ?country" }, "variables": { "?country": { "query": "SELECT ?id WHERE { ?id wdt:P31 wd:Q6256. }" } } } SELECT DISTINCT ?item WHERE { VALUES ?country {wd:Q40 wd:Q39 wd:Q183} ?item (wdt:P31/(wdt:P279*)) wd:Q43099500. { # Director has ?country citizenship ?item wdt:P57 ?director. ?director wdt:P19 ?birth. ?birth wdt:P17 ?country. } UNION { # Director was born in ?country ?item wdt:P57 ?director. ?director wdt:P27 ?country. } UNION { # First performance was in ?country ?item wdt:P4647 ?first_performance_location. ?first_performance_location wdt:P17 ?country. } UNION { # Production company is from ?country ?item wdt:P272 ?production_company. ?production_company wdt:P17 ?country. } }

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#TEMPLATE={ "template": { "en": "Performing arts production 'from' country ?country" }, "variables": { "?country": { "query": "SELECT ?id WHERE { ?id wdt:P31 wd:Q6256. }" } } }
SELECT DISTINCT ?item WHERE {
  VALUES ?country {wd:Q40 wd:Q39 wd:Q183}
  ?item (wdt:P31/(wdt:P279*)) wd:Q43099500.
  { # Director has ?country citizenship
    ?item wdt:P57 ?director.
    ?director wdt:P19 ?birth.
    ?birth wdt:P17 ?country.
  }
  UNION
  { # Director was born in ?country
    ?item wdt:P57 ?director.
    ?director wdt:P27 ?country.
  }
  UNION
  { # First performance was in ?country
    ?item wdt:P4647 ?first_performance_location.
    ?first_performance_location wdt:P17 ?country.
  }
  UNION
  { # Production company is from ?country
    ?item wdt:P272 ?production_company.
    ?production_company wdt:P17 ?country.
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?birth") v1("?country") v3("?director") v5("?first_performance_location") v2("?item"):::projected v6("?production_company") a1((" ")) c3(["wd:Q43099500"]):::iri bind0[/VALUES ?country/] bind0-->v1 bind00(["wd:Q40"]) bind00 --> bind0 bind01(["wd:Q39"]) bind01 --> bind0 bind02(["wd:Q183"]) bind02 --> bind0 v2 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 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; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P272"--> v6 v6 --"wdt:P17"--> v1 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P4647"--> v5 v5 --"wdt:P17"--> v1 end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P57"--> v3 v3 --"wdt:P27"--> v1 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P57"--> v3 v3 --"wdt:P19"--> v4 v4 --"wdt:P17"--> v1 end union0r <== or ==> union0l end