title: How to remove duplicate columns from join in SQL
body: <p>I have the following code</p>
  
  <pre><code>SELECT * 
  FROM customer
  INNER JOIN
      (SELECT   
           customerid, newspapername, enddate, n.publishedby 
       FROM
           newspapersubscription ns, newspaper n 
       WHERE 
           publishedby IN (SELECT publishedby 
                           FROM newspaper 
                           WHERE ns.newspapername = n.NewspaperName)
  UNION
  
  SELECT
      customerid, Magazinename, enddate, m.publishedby 
  FROM
      magazinesubscription ms, magazine m 
  WHERE
      publishedby IN (SELECT publishedby 
                      FROM magazine 
                      WHERE ms.Magazinename = m.MagazineName)) ON customer.customerid = customerid
  ORDER BY 
      customer.customerid;
  </code></pre>
  
  <p>The customer table has the following:</p>
  
  <pre><code> customerid | customername | customersaddress
  </code></pre>
  
  <p>This query returns the following result:</p>
  
  <pre><code>customerid | customername | customersaddress | customerid | newspapername | enddate| publishedby
  </code></pre>
  
  <p>What I actually want is</p>
  
  <pre><code>customerid | customername | customersaddress | newspapername | magazinename | enddate| publishedby
  </code></pre>
  
  <p>Here, the newspapername field should be blank if the magazinename is present and vice versa. Also, the duplicate field of customerid from the union operations should not be present, while in my result, the value of both the newspapername and the magazinename are put under newspapername title. </p>
  
  <p>How can I do that? </p>