Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match exact string literals in SPARQL?

Tags:

sparql

I have this query. It matches anything which has "South" in its name. But I only want the one whose foaf:name is exactly "South".

SELECT Distinct ?TypeLabel 
WHERE
{
    ?a     foaf:name   "South" .
    ?a     rdf:type    ?Type .
    ?Type  rdfs:label  ?TypeLabel .
}
like image 393
Tasawer Khan Avatar asked Apr 07 '10 10:04

Tasawer Khan


1 Answers

a bit late but anyway... I think this is what your looking for:

SELECT Distinct ?TypeLabel Where { 
?a foaf:name ?name . 
?a rdf:type ?Type . 
?Type rdfs:label ?TypeLabel . 
FILTER (?name="South"^^xsd:string)
}

you can use FILTER with the xsd types in order to restrict the result. hope this helps... cheers!

like image 138
Lucas de Oliveira Avatar answered Sep 28 '22 16:09

Lucas de Oliveira