title: SQL: creating unique id for item with several ids
body: <p>I've been pondering this problem for a while and can't find the solution (It might be simple.)</p>
  
  <p>I have a table with two columns which shows which ID's are connected, that is, belonging to the same person. </p>
  
  <p>In this example there are only three individuals, but one of them has three unique IDs.    </p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>PID      | EPID
  ---------+--------
  10004835 | 10004835
  10015375 | 10015375
  10015375 | 10019859
  10019859 | 10015375
  10019859 | 10019859
  10019859 | 10000000
  10000000 | 10019859
  10020104 | 10020104
  </code></pre>
  
  <p>What I want to do is simply to add a column to this table which gives each unique individual a unique code. That is something like </p>
  
  <pre class="lang-none prettyprint-override"><code>PID      | EPID     | NPID
  ---------+----------+-----
  10004835 | 10004835 | 1
  10015375 | 10015375 | 2
  10015375 | 10019859 | 2
  10019859 | 10015375 | 2
  10019859 | 10019859 | 2
  10019859 | 10000000 | 2
  10000000 | 10019859 | 2
  10020104 | 10020104 | 3
  </code></pre>
  
  <p>Ps. I'm using sqlite3 so no recursion in answers please.</p>
  
  <p>Edit: Unless I can find a solution which works for SQLITE3 I will have to use MYSQL instead. In that case, does anyone know a solution which includes recursion?</p>