Advertisement
Guest User

SPARQL 1.1 NOT EXISTS vs. MINUS

a guest
Feb 8th, 2011
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  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. +------------------------+-----+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement