title: Should I use JOIN or UNION for this MYSQL query?
body: <p>I am trying to display data from two different tables ordered by the time the data was created.</p>
  
  <p>Here are the 2 tables I am pulling data from:</p>
  
  <p>active_projects</p>
  
  <pre><code>+------------+------------+---------+-------+-------------+
  | project_id | ts_created | user_id | title | description |
  +------------+------------+---------+-------+-------------+
  </code></pre>
  
  <p>likes</p>
  
  <pre><code>+---------+------------+------------+
  | user_id | project_id | ts_created |
  +---------+------------+------------+
  </code></pre>
  
  <p>The desired result is all of the data retrieved from these columns displayed properly, ordered by this column:</p>
  
  <pre><code>+------------+
  | ts_created |
  +------------+
  </code></pre>
  
  <p>This is the query that I am currently using:</p>
  
  <pre><code>$sql = "SELECT *
          FROM (SELECT project_id AS ppid, 
                       ts_created AS pts,
                       user_id AS puid,
                       title AS ptitle,
                       description AS pdesc
                FROM active_projects 
                WHERE user_id = 12)
          UNION
               (SELECT id AS lid, 
                       user_id AS luid,
                       project_id AS lpid,
                       ts_created AS lts
                FROM likes 
                WHERE user_id = 12)";
  </code></pre>
  
  <p>But, it's not working the way I want to. I've been trying to debug what's going on but right now it's just saying that it's not actually retrieving any of the data.</p>
  
  <p>I have been researching JOIN and UNION but am not sure which one I should be using for this query. Any assistance is greatly appreciated.</p>
  
  <p>EDIT:
  The query is now displaying properly using @Samuel's answer. But, now the results are being displayed 3 times per row.
  I am doing this at the end of the query:</p>
  
  <pre><code>$act = mysql_query($sql);
  </code></pre>
  
  <p>Then, when I echo out the results I am using a while loop likes this:</p>
  
  <pre><code>while ($t = mysql_fetch_row($act)) {
      echo $t[1];
  }
  </code></pre>
  
  <p>Any ideas as to why each row is being displayed 3 times?</p>