title: SPARQL : Find Difference and Common Elements in 2 Sets
body: <p>I am a newbie to SPARQL and struggling to achieve these 2 goals and need your help. I have 2 classes where I have stored the keywords of python and CPP respectively. Now I intend to find the common keywords from these 2 sets and also the difference between the 2 (meaning, keywords which exists in python but not in CPP and vice versa). I have tried MINUS and NOT EXISTS version of the queries but to no help.
  To find the difference in 2 sets, I tried the below query:</p>
  
  <pre><code>SELECT ?subject
      WHERE 
      { ?subject a python:Keywords. 
      { FILTER NOT EXISTS {?subject a cpp:Keywords} }
      }
  </code></pre>
  
  <p>To find the common elements in 2 sets, I tried the below query:</p>
  
  <pre><code>select ?subject
  where{ ?subject a python:Keywords. FILTER  EXISTS { ?object a cpp:Keywords}
  }
  </code></pre>
  
  <p>None of them are working. Please help</p>