query-e858df0cd5a1686a2ed4f23a55203c0f
: As you can see if you try it, the query above return the same embassy twice, because this embassy happens to have two images. I can not place a LIMIT 1 at the end, because there could be several UK-operated items in Germany. PROBLEM: How to limit the number of images to only one? If the item has 3 images, I would like to just pick one of them, I don't care which one. QUESTION: the query below returns an image that has nothing to do with the itemI tried to use LIMIT 1 within the context of the image only, but
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?item ?image WHERE {
?item wdt:P131*/wdt:P17 wd:Q183.
?item wdt:P137 wd:Q145.
{
SELECT ?image {
OPTIONAL {?item wdt:P18 ?image .}
} LIMIT 1
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?image"):::projected
v1("?item"):::projected
a1((" "))
c3(["wd:Q183"]):::iri
c5(["wd:Q145"]):::iri
v1 --"wdt:P131"--> a1
a1 --"wdt:P17"--> c3
v1 --"wdt:P137"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P18".-> v2
end