title: MySQL UNION query return duplicate values even using GROUP BY
body: <p>I have the following query:</p>
  
  <pre><code>SELECT *
  FROM (
      SELECT 
          m.id AS id,
          reference_id, 
          title, 
          created_by, 
          publish_up, 
          state 
      FROM z_news_master m  
      LEFT JOIN z_news_english c ON m.id = c.reference_id
      WHERE c.created_by = 17152
      ORDER by c.id DESC
  ) AS A
  
  UNION
  
  SELECT * FROM (
      SELECT 
          m.id AS id, 
          reference_id,
          title, 
          created_by, 
          publish_up, 
          state 
      FROM z_news_master m  
      LEFT JOIN z_news_spanish c ON m.id = c.reference_id
      WHERE c.created_by = 17152
      ORDER by c.id DESC 
  ) AS B
  GROUP BY id 
  </code></pre>
  
  <p>Basically, I have 3 tables (<code>z_news_master, z_news_english, z_news_spanish</code>), to store News in Spanish or English languages. The <code>z_news_master</code> table contains the generic news information, the <code>z_news_english</code> and <code>z_news_spanish</code> contain the news in its respective language.</p>
  
  <p>I need to get a list of the news, if the news is in both language tables it should return only one (not duplicated), the code above does the work, but if there is a new in English and Spanish, the record gets duplicated.</p>
  
  <p>I'd also like to know why the <code>GROUP BY id</code> and the <code>GROUP BY reference_id</code> don't work?</p>