title: delete all duplicate rows in mySQL 5.7.9
body: <p>I have table like this</p>
  
  <pre><code> select id,channel,post from posts limit 10
  +------+------------+-------+
  | id   | channel    | post  |
  +------+------------+-------+
  | 1433 | channel2   | 19353 |
  | 1434 | channel2   | 19353 |
  | 1435 | channel2   | 19354 |
  | 1436 | channel2   | 19354 |
  | 1437 | channel2   | 19356 |
  | 1438 | channel2   | 19357 |
  | 1439 | channel2   | 19358 |
  | 1440 | channel2   | 19359 |
  | 1441 | channel2   | 19360 |
  | 1634 | channel2   | 19360 |
  +------+------------+-------+
  </code></pre>
  
  <p>in that table <code>id</code> is a <code>primary key</code> , now in that table i have a duplicate post for a channel, i try to add a <code>unique key</code> to table and remove all duplicate row with this query</p>
  
  <pre><code>ALTER ignore TABLE `posts` ADD UNIQUE key `unique_index` (`channel`, `post`);
  </code></pre>
  
  <p>but in <code>mysql 5.7.9</code> we can not do that !</p>
  
  <p>so i want to know how can i delete duplicate row and add a unique key for <code>channel</code>, <code>post</code></p>
  
  <hr>
  
  <p><strong>Solution</strong></p>
  
  <pre><code>    DELETE FROM posts
  WHERE ID Not in (SELECT* 
                   FROM (SELECT MIN(ID)
                         FROM posts 
                         GROUP BY channel, Post) B
                  ) 
  </code></pre>