A.Sim
A.Sim

Reputation: 89

SPARQL if and filtering combination

I want to make a question. I have a sparql query and I want to use (in where clause) filtering only under specific conditions. For example,

I want to say:

SELECT ?country, ?department 
WHERE 
{
IF (?country="USA", FILTER (?department= "Logistics") ).
If (?country="UK", FILTER (?department= "Marketing") ). 
}

I hope that you understood what I want to achieve. Thank you.

Upvotes: 0

Views: 747

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

I don't see the need for IF here but I'm just guessing a solution since your query is rather incomplete:

SELECT * WHERE {
  ?s :country ?country .
  ?s :department ?department .
  VALUES (?country ?department) {
     ( "USA"  "Logistics" )
     ( "UK"  "Marketing" )
  }
}

Upvotes: 1

Related Questions