Want more features on Pastebin? Sign Up, it's FREE!
Guest

SPARQL 1.1 NOT EXISTS vs. MINUS

By: a guest on Feb 8th, 2011  |  syntax: None  |  size: 0.74 KB  |  views: 330  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ### Data
  2.  
  3. @prefix : <http://example.com/> .
  4.  
  5. :a :p 1 ; :q 1,2 .
  6. :b :p 3.0 ; :q 4.0, 5.0 .
  7.  
  8. ### Query 1: NOT EXISTS
  9.  
  10. PREFIX : <http://example.com/>
  11. SELECT * WHERE {
  12.         ?a :p ?n
  13.         FILTER NOT EXISTS {
  14.                 ?a :q ?m .
  15.                 FILTER(?n = ?m)
  16.         }
  17. }
  18.  
  19. +------------------------+-----+
  20. | a                      | n   |
  21. +------------------------+-----+
  22. | <http://example.com/b> | 3.0 |
  23. +------------------------+-----+
  24.  
  25. ### Query 2: MINUS
  26.  
  27. PREFIX : <http://example.com/>
  28. SELECT * WHERE {
  29.         ?a :p ?n
  30.         MINUS {
  31.                 ?a :q ?m .
  32.                 FILTER(?n = ?m)
  33.         }
  34. }
  35.  
  36. +------------------------+-----+
  37. | a                      | n   |
  38. +------------------------+-----+
  39. | <http://example.com/a> | 1   |
  40. | <http://example.com/b> | 3.0 |
  41. +------------------------+-----+
clone this paste RAW Paste Data