Reputation: 175
in a sparql query, I want to list people who are older than 35 years. but I get the following error. what would be the reason?
(The result doesn't change even if I do ?yas > 35
. I still get the error.)
QUERY:
PREFIX uni:<http://muratkilinc.com/~ontologies/izmir.owl#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX un: <http://www.w3.org/2007/ont/unit#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?adi ?soyadi ?yas
WHERE
{
?turistler uni:yas ?yas > "35" .
?turistler uni:yas ?yas.
?turistler uni:adi ?adi.
?turistler uni:soyadi ?soyadi.
}
ERROR:
Error 400: Parse error:
Encountered " ">" "> "" at line 9, column 33.
Was expecting one of:
"values" ...
"graph" ...
"optional" ...
"minus" ...
"bind" ...
"service" ...
"let" ...
"exists" ...
"not" ...
"filter" ...
"{" ...
"}" ...
";" ...
"," ...
"." ...
Upvotes: 0
Views: 57
Reputation: 22042
To put these kinds of boolean conditions in a SPARQL query, you have to use a FILTER
constraint. Like so:
PREFIX uni:<http://muratkilinc.com/~ontologies/izmir.owl#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX un: <http://www.w3.org/2007/ont/unit#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?adi ?soyadi ?yas
WHERE
{
?turistler uni:yas .
?turistler uni:yas ?yas.
?turistler uni:adi ?adi.
?turistler uni:soyadi ?soyadi.
FILTER(?yas > 35)
}
The SPARQL W3C doc is a great resource to read up on what kinds of filter expression you can use, and how to work with different value datatypes (strings, ints, dates, etc.).
Upvotes: 1