Wikidata SPARQL – get name and values for specific items

Something which took me quite some time to find out: how to get the name and some values for items where I already know the ID via SPARQL – usually examples query all items which have something in common (e.g. all cats or so). The magic is the „VALUES“ keyword – it’s actually really easy:

select ?item ?itemLabel ?herisId where {
  ?item wdt:P9154 ?herisId.
  VALUES ?item {wd:Q1534177 wd:Q133495}.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

Try it yourself!

Leave a Reply

You must be logged in to post a comment.