1

i have problem with qualifiers in SPARQL.

I have this query:

SELECT ?title ?item ?date ?place WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P161 wd:Q38111.
  ?item wdt:P1476 ?title.
  ?item wdt:P577 ?date.
  # how add ?place, aka place of publication in P577 of current movie
}

This query shows me movies, where is included Leonardo diCaprio as actor. I want to add another column named "place", which means "place of publication". This place of publication is qualifier of property P577 (date of publication of movie).

Have anybody clue how to do it. Thanks for any advices.

1 Answers1

3

Applying @AKSW's comment to the query is a pretty trivial exercise. Did you try to do this yourself?

SELECT ?title ?item ?date ?place WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P161 wd:Q38111.
  ?item wdt:P1476 ?title.
#  ?item wdt:P577 ?date.
  # how add ?place, aka place of publication in P577 of current movie
  ?item p:P577 ?statement. 
  ?statement ps:P577 ?date. 
  ?statement pq:P291 ?place
}

And to get the placename for each ?place --

SELECT ?title ?item ?date ?place ?placeLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  ?item wdt:P161 wd:Q38111.
  ?item wdt:P1476 ?title.
#  ?item wdt:P577 ?date.
  # how add ?place, aka place of publication in P577 of current movie
  ?item p:P577 ?statement. 
  ?statement ps:P577 ?date. 
  ?statement pq:P291 ?place
}
TallTed
  • 9,069
  • 2
  • 22
  • 37
  • @Alexan if you want to have "text" aka labels, you should make use of the label service which you never did in your query...it's usually `varName` + the Keyword `Label`, e.g. `?placeLabel`, `itemLabel` etc. If you don't want to use this service, then you have to get the label for the `?place` explicitely, i.e. add another triple pattern that does this for you – UninformedUser Dec 19 '18 at 08:49