sparqlwikidata

Get marriage place through a Wikidata SPARQL query


I'm trying desperately via a sparql query to get some info about Megan Markle's weddings like the location of the wedding, but I can't get it. Could you help me? This is what I tried to do:

SELECT ?place
WHERE
{
  wd:Q152316 wdt:P26 [wdt:P2842 ?place].
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Solution

  • wdt: is used for referring to simple triples. You need prefixes p: and pq: to access a qualifier.

    In your case, the query is the following one:

    SELECT ?date ?place
    WHERE {
      wd:Q152316 p:P26 [
        pq:P580 ?date;
        pq:P2842 ?place
      ] .
    }
    

    Take a look at this resource for deepening the topic.

    Extra info: you can find more data about this marriage in a dedicated item (i.e., Q43890449, which is accessible through the P805 qualifier).

    Hence an alternative query is the following one:

    SELECT ?date ?place
    WHERE {
      wd:Q152316 p:P26/pq:P805 ?marriage .
      ?marriage wdt:P585 ?date ;
                wdt:P276 ?place .
    }