Selecting records with the same name give duplicate results
<p>I have a query that scans for people with same name but different ids.
Table structure is Staff(name,id)</p>

<p>What I want to find is people who share the same name but with different id(they are different people).</p>

<p>I do happen to have two people with same name &amp; diff id.</p>

<pre><code>+---------+-----+
|  NAME   | ID  |
+---------+-----+
| John S. | 138 |
| John S. | 491 |
+---------+-----+
</code></pre>

<p>so far I have</p>

<pre><code> select a.name, b.name, a.id, b.id
 from staff a, staff b
 where a.name = b.name and a.id != b.id
</code></pre>

<p>But when I run this code it gives the output twice, which are </p>

<pre><code>+---------+-----+
|  NAME   | ID  |
+---------+-----+
| John S. | 138 |
| John S. | 491 |
| John S. | 491 |
| John S. | 138 |
+---------+-----+
</code></pre>

<p>I know why this happens because these two outputs both satisfy the checking condition, but is there anyway I can suppress ones that are already outputted? I can run a select table and WHERE ROWNUM &lt;= 2 but that wont be the optimal case when I have more people with same names.</p>

<p>Thanks!</p>