title: MySQL: How to select distinct values from a table?
body: <p>I have huge table with many rows and columns, but I will describe only important of them:</p>
  
  <pre><code>+-----------+------------------+------+-----+---------+----------------+
  | Field     | Type             | Null | Key | Default | Extra          |
  +-----------+------------------+------+-----+---------+----------------+
  | id        | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
  | name      | varchar(255)     | NO   |     | NULL    |                |
  | artikel   | int(10) unsigned | NO   | IDX | NULL    |                |
  | color     | varchar(255)     | NO   |     | NULL    |                |
  +-----------+------------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>Example data:</p>
  
  <pre><code> 1    apple        1000      red
   2    apple        1000      yellow
   3    lemon        2000      blue
   4    lem on       2000      green
   5    lemon        2000      black
   6    apple        1000      white
   7    cherry       3000      lime
   8    cherry       3000      pink
   9    lemon        2000      silver
  10    apple        1000      gold
  </code></pre>
  
  <p>As you can see, the index is on <code>artikel</code>, each <code>artikel</code> has some <code>name</code> (for each <code>artikel</code> there is the same <code>name</code>) and different <code>color</code>. Everything is OK, but with row <code>4</code> there is problem, there is wrong <code>name</code> = <code>lem on</code>, it should be <code>lemon</code>.</p>
  
  <p>I want to select these rows (<code>GROUP BY artikel</code>), where there is not unique <code>name</code>, but <code>HAVING COUNT(name) &gt; 1</code>. So my select will return one row, where will be <code>artikel</code> = <code>2000</code>.</p>
  
  <p>I tried <code>HAVING</code>, <code>DISTINCT</code>, but with no success.</p>
  
  <p>How can be done that?</p>