Suppose I have a RDF-base containing 4 triples:
"John" "loves" "sushi"
"John" "loves" "Mary"
"Frank" "hates" "sushi"
"John" "hates" "olives"
and let's say I consider "sushi" such a weird thing that I'd like to know what exactly people can do with it and even more what else they can apply the same action to =)
So I write a SPARQL query that seems logical to me:
SELECT ?s ?o WHERE
{
?s ?p "sushi".
?s ?p ?o
}
naturally expecting to get the following result
"John" "sushi"
"John" "Mary"
"Frank" "sushi"
because for each of the first 3 triples there exists a satisfying pair of (?s, ?p) values that makes the joined pattern evaluate to TRUE.
But in reality (I use local 4store engine & DB) the answer is like this:
"John" "sushi"
"John" "Mary"
"Frank" "sushi"
"John" "olives"
Can someone explain this behavior to me?
And if this is truly how it should work in SPARQL, then what is the way to get what I need?