title: SQL query Exists AND NOT Exists
body: <p>I have a table where I need to insert the data from a view which has 2 conditions :
  1) Insert those data in a table where pk is unavailable in a transaction table but is available in the view 2) if pk is there but data is different from the view then insert those data also </p>
  
  <pre><code>        Insert into table A
      a,
      b,
      c,
      d
  SELECT 
  a,
  b,
  c,
  d
  from View sa
  WHERE not Exists 
  (Select * FROM table A q
      where SA.a = q.a )
      OR 
      CASE WHEN  Exists
      (Select * FROM table A q
      where SA.a = q.a 
      AND 
  
  
                          SA.b &lt;&gt; q.b
                          OR SA.c &lt;&gt; q.c
                          OR SA.d &lt;&gt; q.d
                      ) 
  </code></pre>
  
  <p>Any help appreciated! </p>