title: Mysql Union two tables with different values
body: <p>I need to return all the values from one table and then join this table to another query without duplicating values. This is my query so far.</p>
  
  <pre><code>    CREATE TABLE tmp_tbl (Id INT(11) PRIMARY KEY, Per VARCHAR(30), Des VARCHAR(50), Rol INT(11));
  INSERT INTO tmp_tbl(Id, Per, Des, Rol)
  SELECT DISTINCT
       p.p_id AS Id,
      p.p_title AS Per,
      p.p_description AS Des,
      '' AS Rol
      FROM perm p;
  
   SELECT  
      p.p_id AS Id,
      p.p_title AS Per,
      p.p_description AS Des,
      r.id AS Rol
      FROM perm p
      LEFT JOIN roles rp
          ON p.p_id = rp.p_id
      INNER JOIN rol r
          ON r.id = rp.r_id AND rp.r_id IN (101)
      UNION  ALL
  SELECT * FROM
  tmp_tbl;
   DROP TABLE tmp_tbl;
  </code></pre>
  
  <p>The statement returns all the rows from the first select but duplicates the rows on the union from the second select statement. </p>