title: Mysql Query for unique slugs
body: <p>I have made a wordpress plugin to find and replace keywords in database, where admin provides keywords to find and to replace, and then the MYSQL query does the changes in DB.<br>
  But all I want to know the way to avoid the duplicate slugs.<br>
  For example :<br>
  As if there are two posts with following slugs: </p>
  
  <ol>
  <li>firstpost</li>
  <li>secondpost</li>
  </ol>
  
  <p>and then admin runs the query and wants to replace "second" with "first".
  then the result will be:</p>
  
  <pre><code>update wp_posts set `post_name` = replace(post_name, 'second','first') where post_type='post'
  </code></pre>
  
  <ol>
  <li>firstpost</li>
  <li>firstpost</li>
  </ol>
  
  <p>Is there a way to keep the slugs unique ?</p>