title: Generate unique username from first and last name?
body: <p>I've got a bunch of users in my database and I want to reset all their usernames to the first letter of their first name, plus their full last name. As you can imagine, there are some dupes. In this scenario, I'd like to add a "2" or "3" or something to the end of the username. How would I write a query to generate a unique username like this?</p>
  
  <pre><code>UPDATE user
  SET username=lower(concat(substring(first_name,1,1), last_name), UNIQUETHINGHERE)
  </code></pre>