title: Postgres get rows with one same column value
body: <p>In Postgres I have a table as below:</p>
  
  <p>Table <code>phones</code></p>
  
  <pre><code> |id | phone        |
   | 1 | +12345678    |
   | 2 | +95687445    |
   | 3 | +78945646    |
   | 4 | +12345678    |
  </code></pre>
  
  <p>As you can see <code>id</code> <code>1</code> and <code>4</code> have the same phone number.</p>
  
  <p>I want to get all rows which has same phone number but different <code>id</code> like this:</p>
  
  <pre><code> | id1 | id2 | phone     |
   | 1   | 4   | +12345678 |
  </code></pre>
  
  <p>I have tried to use <code>JOIN</code> with itself but that returns duplicate results:</p>
  
  <pre class="lang-sql prettyprint-override"><code>select
    p1.id as id1,
    p2.id as id2,
    p1.phone
  from phones as p1
    join phones as p2
      on p1.phone = p2.phone
  </code></pre>
  
  <pre><code> | id1 | id2 | phone     |
   | 1   | 4   | +12345678 |
   | 4   | 1   | +12345678 |
  </code></pre>