title: Prevent duplicate values in LEFT JOIN
body: <p>I faced a situation where I got duplicate values from <code>LEFT JOIN</code>. I think this might be a desired behavior but unlike from what I want.</p>
  
  <p>I have three tables: <strong><code>person</code></strong>, <strong><code>department</code></strong> and <strong><code>contact</code></strong>.</p>
  
  <p><strong>person :</strong></p>
  
  <pre><code>id bigint,
  person_name character varying(255)
  </code></pre>
  
  <p><strong>department :</strong></p>
  
  <pre><code>person_id bigint,
  department_name character varying(255)
  </code></pre>
  
  <p><strong>contact :</strong></p>
  
  <pre><code>person_id bigint,
  phone_number character varying(255)
  </code></pre>
  
  <p><strong>Sql Query :</strong></p>
  
  <pre><code>SELECT p.id, p.person_name, d.department_name, c.phone_number 
  FROM person p
    LEFT JOIN department d 
      ON p.id = d.person_id
    LEFT JOIN contact c 
      ON p.id = c.person_id;
  </code></pre>
  
  <p><strong>Result :</strong></p>
  
  <pre><code>id|person_name|department_name|phone_number
  --+-----------+---------------+------------
  1 |"John"     |"Finance"      |"023451"
  1 |"John"     |"Finance"      |"99478"
  1 |"John"     |"Finance"      |"67890"
  1 |"John"     |"Marketing"    |"023451"
  1 |"John"     |"Marketing"    |"99478"
  1 |"John"     |"Marketing"    |"67890"
  2 |"Barbara"  |"Finance"      |""
  3 |"Michelle" |""             |"005634"
  </code></pre>
  
  <p>I know it's what joins do, keeping multiplied with selected rows. But It gives a sense like phone numbers <code>023451</code>,<code>99478</code>,<code>67890</code> are for both departments while they are only related to person john with unnecessary repeated values which will escalate the problem with larger data set. 
  <br>So, here is what I want:</p>
  
  <pre><code>id|person_name|department_name|phone_number
  --+-----------+---------------+------------
  1 |"John"     |"Finance"      |"023451"
  1 |"John"     |"Marketing"    |"99478"
  1 |"John"     |""             |"67890"
  2 |"Barbara"  |"Finance"      |""
  3 |"Michelle" |""             |"005634"
  </code></pre>
  
  <p>This is a sample of my situation and I am using a large set of tables and queries. So, kind of need a generic solution.</p>