title: mysql problem with union/join used in conjunction
body: <p>I have these two tables:</p>
  
  <p>Table Author:</p>
  
  <pre><code>ID (INTEGER),
  author_name (VARCHAR),
  first_name (VARCHAR),
  last_name (VARCHAR),
  preferred_name (VARCHAR)
  </code></pre>
  
  <p>Table CoAuthored:</p>
  
  <pre><code>ID (INTEGER)
  author1ID (INTEGER),
  author2ID (INTEGER),
  paper_ID (INTEGER) // (ID of the co-authored paper referenced by this link)
  </code></pre>
  
  <p>As you can see, both tables have a column 'ID', but they are unrelated.</p>
  
  <p>However, when I use this query:</p>
  
  <pre><code>select author_name, count(*) as NumPapers from
  (select * from Author as a join CoAuthored as c on a.ID = c.author1ID
  union distinct
  select * from Author as b join CoAuthored as d on b.ID = d.author2ID) as t1
  group by author_name
  order by NumPapers;
  </code></pre>
  
  <p>mySQL gves me an error saying: <code>ERROR 1060 (42S21): Duplicate column name 'ID'</code></p>
  
  <p>Why does this happen and how do I avoid it?</p>