Created on Feb. 23, 2013, 12:27 p.m. by Hevok & updated by Hevok on May 2, 2013, 5:19 p.m.

Negation allows to refer to conditions where an answer exists or does not exists.

For instance making a small select statement on a database with three individuals in it for which not all the name is given but the type Person is defined.

If one wants to select all person from a database where one specific attribute is not available then one can do this with the filter expression NOT EXISTS, where one can say FILTER NOT EXIST the name, or a Triple that has a foaf name in it. With such a simple filter NOT EXISTS one can filter out results and therefore give specific things that should not be provides in the results.

  • Filter of Query solutions is done within a FILTER expression using NOT EXISTS and EXISTS


@prefix : <http://example/>] .
@prefix rdf: <>]
@prefix foaf: <>] .

:hevok rdf:type foaf:Person .
:hevok foaf:name "Hevok" .
:eva   rdf:type foaf:Person .


PREFIX rdf: <>]
PREFIX foaf: <http://xmlns/foaf/0.1/>]
SELECT ?person
    ?person rdf:type foaf:Person .
    FILTER NOT EXISTS { ?person foaf:name ?name }



Tags: query, coding, programming, existance
Categories: Tutorial
Parent: SPARQL 1.1

Update entry (Admin) | See changes

Comment on This Data Unit