I am using the Wikidata Query Service (https://query.wikidata.org) to get details about movies and Tv shows.
I know I can query for genre of all items that are instance of film (query below) but I want to look for just specific movies.
SELECT ?item ?itemLabel ?genreLabel
WHERE
{
?item wdt:P31 wd:Q11424 .
OPTIONAL {
?item wdt:P136 ?genre
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} LIMIT 10
I have a list of the Wikidata item numbers (Q###) for movies and Tv shows that I want to get properties about. I need to query these specific films or TV shows. For example, if I know that Star Wars Episode IV: A New Hope is Q17738 in Wikidata, how can I query for specific properties of it?
There are (at least) two ways of specifying multiple items in SPARQL.
FILTER (?item IN (...list...))
: SPARQL definitionVALUES ?item { ...list... }
: SPARQL definitionThe difference is that
IN
is simply a function: is argument in this list?VALUES
is a way to pass in data to a query. Although we used the simple form you can provide full, tabular data:The syntax has a special case for one variable, so I didn't have to write
VALUES ?item { (wd:Q17738) (wd:Q181795) }
.