title: How to compare two tables in Postgresql?
body: <p>I have two identical tables:</p>
  
  <pre><code>A :   id1, id2, qty, unit
  B:    id1, id2, qty, unit
  </code></pre>
  
  <p>The set of <code>(id1,id2)</code> is identifying each row and it can appear only once in each table.</p>
  
  <p>I have <code>140</code> rows in table <code>A</code> and <code>141 rows</code> in table <code>B</code>.
  I would like to find all the keys (id1,id2) that are not appearing in both tables. There is 1 for sure but there can't be more (for example if each table has whole different data).</p>
  
  <p>I wrote this query:</p>
  
  <pre><code>(TABLE a EXCEPT TABLE b)
  UNION ALL
  (TABLE b EXCEPT TABLE a) ;
  </code></pre>
  
  <p>But it's not working. It compares the whole table where I don't care if <code>qty</code> or <code>unit</code> are different, I only care about <code>id1,id2</code>.</p>