%META:TOPICPARENT{name="VirtTipsAndTricksSPARQL11FeaturesExamplesCollection"}%
---+ Virtuoso SPARQL 1.1. NOT EXISTS and MINUS
---++What?
This guide contains example queries using SPARQL 1.1 NOT EXISTS
and MINUS
, which you should be able to run against any SPARQL 1.1 endpoint.
---++Why?
NOT EXISTS
and MINUS
offer flexible ways to check for the absence of a given pattern, or to exclude possible solutions from the result set.
---++How?
Here are some examples showcasing Virtuoso's support for this functionality:
---+++NOT EXISTS
SELECT COUNT(*)
WHERE
{
?s ?p "Novosibirsk"
FILTER
NOT EXISTS { ?s ?p "???????????" }
}
* [[http://bit.ly/WCQsvi][View the SPARQL Query Definition via SPARQL Protocol URL]]
* [[http://bit.ly/16GYhmC][View the SPARQL Query Results via SPARQL Protocol URL]]
---+++MINUS
SELECT COUNT(*)
WHERE
{
{ ?s ?p "Novosibirsk" }
MINUS
{ ?s ?p "???????????" }
}
* [[http://bit.ly/XZTlID][View the SPARQL Query Definition via SPARQL Protocol URL]]
* [[http://bit.ly/ZH6VfM][View the SPARQL Query Results via SPARQL Protocol URL]]
---++Related
* [[http://www.w3.org/TR/sparql11-query/#neg-notexists-minus][SPARQL 1.1. -- Relationship and differences between NOT EXISTS and MINUS]]
* [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]]
* [[VirtTipsAndTricksSPARQL11FeaturesExamplesCollection][Virtuoso SPARQL 1.1 Usage Examples Collection]]
* [[http://virtuoso.openlinksw.com/tutorials/sparql/SPARQL_Tutorials_Part_9/SPARQL_Tutorials_Part_9.html][Virtuoso SPARQL 1.1 Syntax Tutorial]]