<docbook><section><title>VirtTipsAndTricksGuideSPARQLNOTEXISTS</title><title> Virtuoso SPARQL 1.1.
 NOT EXISTS and MINUS</title> Virtuoso SPARQL 1.1.
 NOT EXISTS and MINUS
<bridgehead class="http://www.w3.org/1999/xhtml:h2">What?</bridgehead>
 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.<bridgehead class="http://www.w3.org/1999/xhtml:h2">Why?</bridgehead>
 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.<bridgehead class="http://www.w3.org/1999/xhtml:h2">How?</bridgehead>
<para>Here are some examples showcasing Virtuoso&#39;s support for this functionality:</para>
<para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">NOT EXISTS</bridgehead>
<programlisting>SELECT COUNT(*) 
WHERE 
  {
    ?s ?p &quot;Novosibirsk&quot;  
    FILTER 
      NOT EXISTS { ?s ?p &quot;???????????&quot; } 
  }
</programlisting><itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://bit.ly/WCQsvi">View the SPARQL Query Definition via SPARQL Protocol URL</ulink> </listitem>
<listitem><ulink url="http://bit.ly/16GYhmC">View the SPARQL Query Results via SPARQL Protocol URL</ulink></listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3">MINUS</bridgehead>
 <programlisting>SELECT COUNT(*) 
WHERE 
  { 
    { ?s ?p &quot;Novosibirsk&quot; } 
    MINUS 
    { ?s ?p &quot;???????????&quot; }
  }
</programlisting><itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://bit.ly/XZTlID">View the SPARQL Query Definition via SPARQL Protocol URL</ulink> </listitem>
<listitem><ulink url="http://bit.ly/ZH6VfM">View the SPARQL Query Results via SPARQL Protocol URL</ulink></listitem>
</itemizedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="http://www.w3.org/TR/sparql11-query/#neg-notexists-minus">SPARQL 1.1. -- Relationship and differences between NOT EXISTS and MINUS</ulink> </listitem>
<listitem><ulink url="VirtTipsAndTricksGuide">Virtuoso Tips and Tricks Collection</ulink> </listitem>
<listitem><ulink url="VirtTipsAndTricksSPARQL11FeaturesExamplesCollection">Virtuoso SPARQL 1.1 Usage Examples Collection</ulink> </listitem>
<listitem><ulink url="http://virtuoso.openlinksw.com/tutorials/sparql/SPARQL_Tutorials_Part_9/SPARQL_Tutorials_Part_9.html">Virtuoso SPARQL 1.1 Syntax Tutorial</ulink></listitem>
</itemizedlist></section></docbook>