title: how to delete duplicate rows from a table in mysql
body: <p>I need to delete duplicate record from table in mysql.
  So i have a table name &quot;employee&quot; fields are empid, empname, empssn</p>
  <p>for getting duplicate record i have written a query</p>
  <pre><code>SELECT COUNT(empssn), empssn FROM employee 
  GROUP BY empssn 
  HAVING COUNT(empssn) &gt; 1
  </code></pre>
  <p>Now I want to delete duplicate records. For that I have written query is.</p>
  <pre><code>DELETE FROM employee 
  WHERE (empid, empssn) NOT IN (
      SELECT MIN(empid), empssn FROM employee 
      GROUP BY empssn
  );
  </code></pre>
  <p>you can assume records in table are</p>
  <pre><code>EmpId  EmpName  EmpSSN
  -------------------------------
   1     Jack     555-55-5555
   2     Joe      555-56-5555
   3     Fred     555-57-5555
   4     Mike     555-58-5555
   5     Cathy    555-59-5555
   6     Lisa     555-70-5555
   7     Jack     555-55-5555
   8     Mike     555-58-5555
   9     Cathy    555-59-5555
  10     Lisa     555-70-5555
  11     Lisa     555-70-5555
  </code></pre>
  <p>but I have a mysql error is</p>
  <blockquote>
  <p>You can't specify target table 'employee' for update in FROM clause</p>
  </blockquote>