query-dfd3cc48456b4c303fd435c84b2749fb
Combine two queries to match paintings with paintersI have two collections of paintings that don't include the full name of the painter. This gives the paintings missing the creator:
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT ?item ?description WHERE {
?item wdt:P31 wd:Q3305213 .
{ ?item wdt:P195 wd:Q18600731 } UNION { ?item wdt:P195 wd:Q28045665 } .
MINUS { ?item p:P170 [] } .
?item schema:description ?description .
FILTER(LANG(?description) = "en")
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?description"):::projected
v2("?item"):::projected
a1((" "))
c3(["wd:Q3305213"]):::iri
c5(["wd:Q18600731"]):::iri
c6(["wd:Q28045665"]):::iri
f0[["?description = 'en'"]]
f0 --> v1
v2 --"p:direct/P31"--> c3
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P195"--> c6
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P195"--> c5
end
union0r <== or ==> union0l
end
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v2 --"p:P170"--> a1
end
v2 --"schema:description"--> v1