title: How to generate random string to salt passowrd in sql?
body: <p>Got a question salting passwords in sql:</p>
  
  <p>The code below salts a particular password by randomly generating a 10 character string:</p>
  
  <pre><code>Update Teacher 
  SET    TeacherSalt = SUBSTRING(MD5(RAND()), -10), 
         TeacherPassword = SHA1(CONCAT('009b9b624aaecc4b3217dcd4bfee15ab704745d7',SUBSTRING(MD5(RAND()), -10)))
  WHERE TeacherPassword = '009b9b624aaecc4b3217dcd4bfee15ab704745d7'
  </code></pre>
  
  <p>But what my question is that I want to change the salt so that the string it is generating comes from all of these characters:</p>
  
  <p>./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789</p>
  
  <p>There are 63 characters. The php way of doing this is below:</p>
  
  <pre><code>$salt = ""; 
  for ($i = 0; $i &lt; 40; $i++) { 
     $salt .= substr(
       "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 
       mt_rand(0, 63), 
       1); 
  }
  </code></pre>
  
  <p>But how can I write this in the sql way above?</p>