title: MySQL: How to retrieve all rows with a duplicate field, matching a LIKE on a certain field in any matched row
body: <p>I have a database containing about 300,000 rows of product information.<br>
  I need to retrieve rows with <strong>duplicate UPCs</strong> (COUNT(upc) > 1), where <strong>at least one</strong> of the results' descriptions matches a certain string ("Reed", for example.)</p>
  
  <p>For example, the following rows would all be selected (desc, upc pairs)</p>
  
  <pre><code>Deer D7394    62226173
  Reed R2536    62226173
  Deer D7217    62226173
  </code></pre>
  
  <p>but none of</p>
  
  <pre><code>Deer D0173    62278389
  Deer D7289    62278389
  Deer D9272    62278389
  </code></pre>
  
  <p>Here is the query I'm working with:</p>
  
  <pre><code>SELECT a.desc, a.upc, a.sku, a.short_description 
  FROM inventory a 
  JOIN 
      (SELECT upc, desc 
      FROM inventory 
      GROUP BY upc 
      HAVING COUNT(upc) &gt; 1) b 
  ON a.upc = b.upc 
  WHERE ((a.desc LIKE '%Reed%') OR (b.desc LIKE '%Reed%'))
  AND a.upc != '' 
  AND a.upc != 0 
  ORDER BY upc;
  </code></pre>
  
  <p>I am relatively new to MySQL, but this seems like it should work. However, <strong>some</strong> results are failing to return the non-matching row (i.e. Reed R2536 will be returned, but not Deer D7394).</p>
  
  <p>Any insight would be greatly appreciated!</p>