title: Remove Duplicate Results by a Group due to JOIN same Ids
body: <p>My MySQL query keeps creating duplicate entries. I think it is to do with my join or ID values.
  I am new to <code>JOIN</code> and I am trying to do a fairly simple <code>JOIN</code> and filter. </p>
  
  <p>Basically I am filtering products on a product listing page.</p>
  
  <p><code>newCatCols</code></p>
  
  <pre><code>+----+-----------------+-------------+
  | id | sku             | name        |
  +----+-----------------+-------------+  
  |  1 | 670_apple       | Black       |
  |  2 | 670_apple       | Apple       |
  |  3 | 670_apple       | Blush       |
  |  4 | 670_apple       | Turquoise   |
  |  5 | 670_apple       | Light Coral |
  | 10 | 640_apple_black | Apple_Black |
  | 22 | 347_blush       | Lime        |
  | 33 | 347_blush       | Turquoise   |
  | 44 | 347_blush       | Gray        |
  | 55 | 347_blush       | Yellow      |
  +----+-----------------+-------------+
  </code></pre>
  
  <p><code>newCatProds</code></p>
  
  <pre><code>+----+-----------------+--------+------+
  | id | sku             | cost   | cat  |
  +----+-----------------+--------+------+    
  |  1 | 670_apple       | 489.55 | swar |
  | 10 | 640_apple_black | 458.99 | swar |
  | 22 | 347_blush       | 741.44 | sig  |
  +----+-----------------+--------+------+    
  </code></pre>
  
  <p>If the custom chooses Black, I want it to return colours with Black, and Apple_Black and Apple. It just duplicates listings though:</p>
  
  <pre><code>// productslisting.php?cat=swar&amp;filter=Black
  $strColourGet=mysql_real_escape_string($_GET["filter"]);
  $strCatGet=mysql_real_escape_string($_GET["cat"]);  
  
  if($strColourGet=="Black"){
  
  $checkSQL=mysql_query("
  SELECT * FROM `newCatProds`
  INNER JOIN `newCatCols`
  ON `newCatProds`.`sku` = `newCatCols`.`sku`
  WHERE (
      `name` = 'Black' OR
      `name` = 'Apple' OR
      `name` = 'Apple_Black' 
  )
  AND `status`='1' AND `category` = '".$strCatGet."'
  ORDER BY `newCatProds`.`rank` DESC");
  
  }
  </code></pre>
  
  <p>Results appear twice though. Can I somehow not have it appear twice?</p>
  
  <pre><code>710     702_appleblack  139         sig     0   8   1   1   1243    702_appleblack  Apple_Black
  486     613_turq    139         sig     0   124     1   1   695     613_turq    Black
  463     379_sapphire2   139         sig     0   46  1   1   652     379_sapphire2   Black
  504     670_apple   119         sig     0   176     1   1   607     670_apple   Black
  463     379_sapphire2   139         sig     0   46  1   1   658     379_sapphire2   Apple_Black
  </code></pre>
  
  <p>So maybe a group? So the <code>379_sapphire2</code> should only appear ONCE as it has both in?</p>