Casey Nwan
Casey Nwan

Reputation: 13

getting the label and description of wikidata item as well as specified properties labels and description

i am relatively new to sparql and i need to get the label/title of the wikidata item as well as other specified properties' label and description.

my code gives me only the properties' label and description but i cannot get the label/title and description of the wikidata item(qid). the label/title of the wikidata item(qid) - Building at Rua Esteves Junior, 26 and description of the wikidata item(qid) - historical site registered by State Institute of Cultural Heritage of Rio de Janeiro in the city of Rio de Janeiro, Rio de Janeiro, Brazil

my code:


SELECT ?locationDescription ?locationLabel ?streetLabel ?descriptionLabel ?countryLabel ?heritageLabel WHERE {
    
    wd:Q69363514 wdt:P131 ?location.
    wd:Q69363514 wdt:P6375 ?street.
    wd:Q69363514 wdt:P973 ?description.
    wd:Q69363514 wdt:P17 ?country.
    wd:Q69363514 wdt:P1435 ?heritage.
       SERVICE wikibase:label {
         bd:serviceParam wikibase:language "en" .
       }
    }


Upvotes: 1

Views: 176

Answers (1)

You could use VALUES:

SELECT 

  ?item ?itemLabel ?itemDescription 
  ?locationDescription ?locationLabel 
  ?streetLabel 
  ?descriptionLabel 
  ?countryLabel 
  ?heritageLabel 

WHERE {
    
  VALUES ?item { wd:Q69363514 }
  
  ?item wdt:P131 ?location ;
        wdt:P6375 ?street ;
        wdt:P973 ?description ;
        wdt:P17 ?country ;
        wdt:P1435 ?heritage .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }

}

This would also allow you to query multiple items at once:

VALUES ?item { wd:Q69363514 wd:… wd:… }

Upvotes: 0

Related Questions