title: Select query with unique random numer
body: <p>I'd like to create an SQL statement to select all my data from a table (about 5000 entries) and to assign to each row a unique random number (between 100000 and 999999).</p>
  
  <p>How can I ensure that each random number is unique?</p>
  
  <p>If I try something like</p>
  
  <pre><code>SELECT pid, FLOOR(RAND() * (999999 - 100000 + 1)) + 100000 as 'RanNum' FROM mytable
  </code></pre>
  
  <p>and check (e.g in Excel), at least some RanNum are duplicates. How can I prevent this in a query?</p>
  
  <p>Thanks!</p>