Random uniqueID for each ID SQL How can I improve this code? I wanted to know if there's a possibility to remove the for loop, and UPDATE a different uniqueID for each ID in my database.

&lt;?php

  $reponse = $bdd-&gt;prepare("SELECT MAX(ID) FROM tuto WHERE title=''");
  $reponse-&gt;execute();

  $IDnow = $reponse-&gt;fetch(PDO::FETCH_ASSOC);
  $IDnow = $IDnow['MAX(ID)'];

  for ($i=2 ; $i &lt;= $IDnow ; $i++){

     $reponse = $bdd-&gt;prepare("UPDATE tuto SET uniqueID=:uniqueID WHERE uniqueID='' AND title='' AND ID=:i");

     $uniqueID = $donnees['uniqueID'];

     $int = rand(0,51);
     $a_z = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     $uniqueID = time().$a_z[$int];

     $reponse-&gt;execute([':uniqueID' =&gt; $uniqueID, 'i' =&gt; $i]);
  }
?&gt;
Finally, I used RAND(), for generate an "UniqueID", and we can add some letters after or else :

Thanks to NerdyDev and Bart Friederichs for solutions.

&lt;?php

$reponse = $bdd-&gt;prepare("UPDATE tuto SET uniqueID=ROUND(RAND() * :tp) WHERE uniqueID='' AND title=''");

$uniqueID = $donnees['uniqueID'];

$tp = time();
$reponse-&gt;execute([':tp' =&gt; $tp]);

?&gt;