title: How to combine two tables (with same schema) into a single table with distinct values and indicating which table each row came from?
body: <p>Suppose that I have two tables in SQL:</p>
  
  <pre><code>Table_Alpha   Table_Bravo
  Id | Name     Id | Name
  ---+------    ---+-----
   1 | Alice     1 | Charlie
   2 | Bob       2 | Bob
   3 | Charlie   3 | Dorothy
  </code></pre>
  
  <p>I want to combine the two tables into a single table, avoiding duplicates and keeping track of which table each name came from like so:</p>
  
  <pre><code>Result
  Name   | Alpha | Bravo
  -------+-------+------
  Alice  |   1   |   0  
  Bob    |   1   |   1  
  Charlie|   1   |   1  
  Dorothy|   0   |   1  
  </code></pre>
  
  <p>I think that the query that I want will look something like this:</p>
  
  <pre><code>SELECT Name, 1 AS Alpha, 0 AS Bravo FROM Table_Alpha
  UNION
  SELECT Name, 0 AS Alpha, 1 AS Bravo FROM Table_Bravo;
  </code></pre>
  
  <p>However, the above query will return two rows for each name that appears in both tables.  How can I write the query so that it will return one row for each distinct name?</p>