Assigning specific values to multiple variable in SPARQL

Viewed 151

I am trying to query the WikiData database using their SPARQL endpoint. Here I want to assign specific values to certain variables independent from each other. I know that the VALUES keyword can be used for this, however, is there a way of doing this for multiple variables without having to specify each possible combination? For example, the query looks like this:

SELECT ?relation1 ?item1?
     WHERE {wd:Q31 ?relation1 ?item1 .}

I would like to specify the values for both ?relation1 and ?item1 without having to go over each possible combination.

Thank you.

1 Answers

Edited answer: Yes, you can use multiple VALUES statements. This can be written like this:

SELECT *
WHERE {
  VALUES ?person {wd:Q35332 wd:Q23844} #Brad Pitt and Geroge Clooney
  VALUES ?property {wdt:P27 wdt:P19} #Country of nationality and place of birth
  ?person ?property ?o ;
          rdfs:label ?personLabel .

  ?o rdfs:label ?oLabel .

  FILTER(LANG(?personLabel) = 'en' && LANG(?oLabel) = 'en')
  }

You will then see these results: enter image description here

This link will contain more information.

Related