title: SQL how to simulate an xor?
body: <p>I'm wondering if anybody can help me solve this question I got at a job interview. Let's say I have two tables like:</p>
  
  <pre><code>table1                 table2
  ------------           -------------
  id | name              id | name
  ------------           -------------
   1 | alpha              1 | alpha
   3 | charlie            3 | charlie
   4 | delta              5 | echo
   8 | hotel              7 | golf
   9 | india
  </code></pre>
  
  <p>The question was to write a SQL query that would return all the rows that are in either <code>table1</code> or <code>table2</code> but not both, i.e.:</p>
  
  <pre><code>result
  ------------
  id | name
  ------------
   4 | delta
   5 | echo
   7 | golf
   8 | hotel
   9 | india
  </code></pre>
  
  <p>I thought I could do something like a full outer join: </p>
  
  <pre><code>SELECT table1.*, table2.* 
  FROM table1 FULL OUTER JOIN table2 
  ON table1.id=table2.id 
  WHERE table1.id IS NULL or table2.id IS NULL
  </code></pre>
  
  <p>but that gives me a syntax error on SQL Fiddle (I don't think it supports the <code>FULL OUTER JOIN</code> syntax). Other than that, I can't even figure out a way to just concatenate the rows of the two tables, let alone filtering out rows that appear in both. Can somebody enlighten me and tell me how to do this? Thanks.</p>