title: How to get rid off duplicate records with same color or size using MySQL query
body: <p><strong>Initial SQL Query Result</strong></p>
  <pre><code>pkid    catpkid subcatpkid  title       description     createdatetime          visible     listprice   ourprice    memberprice     subcattitle largephotofilename  cattitle    colortitle  sizetitle   
  132     5       118         Title01     Desc01          2020-07-15 14:44:51     YES         1599.00     570.00      470.00          SubCat01    image001.jpeg       cat001      Gray        L
  132     5       118         Title01     Desc01          2020-07-15 14:44:51     YES         1599.00     570.00      470.00          SubCat01    image001.jpeg       cat001      Gray        XL
  132     5       118         Title01     Desc01          2020-07-15 14:44:51     YES         1599.00     570.00      470.00          SubCat01    image001.jpeg       cat001      Gray        XXL
  135     5       118         Title02     Desc02          2020-07-15 16:26:52     YES         1599.00     570.00      470.00          SubCat01    image002.jpeg       cat001      Pink        L
  135     5       118         Title02     Desc02          2020-07-15 16:26:52     YES         1599.00     570.00      470.00          SubCat01    image002.jpeg       cat001      Pink        XL
  135     5       118         Title02     Desc02          2020-07-15 16:26:52     YES         1599.00     570.00      470.00          SubCat01    image002.jpeg       cat001      Pink        XXL
  135     5       118         Title02     Desc02          2020-07-15 16:26:52     YES         1599.00     570.00      470.00          SubCat01    image002.jpeg       cat001      Pink        XXXL
  </code></pre>
  <p>Initially I was getting above SQL result where duplicate products were displaying in SQL result due to same product color and different sizes. Then I got help here and I used below query which is working fine now. I am getting below SQL result now where only first product with same pkid and color is displaying in SQL result.</p>
  <p><strong>Current SQL Query I am using</strong></p>
  <pre><code>SELECT a.pkid, 
  b.subcattitle, 
  c.largephotofilename,  
  d.title AS cattitle, 
  f.title AS colortitle, 
  min(n.title) AS sizetitle 
  FROM t_store a 
  LEFT JOIN t_store_cat d ON a.catpkid=d.catpkid AND d.visible='YES' 
  LEFT JOIN t_store_subcat b ON a.subcatpkid=b.subcatpkid 
  LEFT JOIN tr_store_photo c ON a.pkid=c.masterpkid 
  LEFT JOIN tr_store_color e ON a.pkid=e.itempkid 
  LEFT JOIN t_store_color f ON e.masterpkid=f.pkid 
  LEFT JOIN tr_store_size m ON a.pkid=m.itempkid 
  LEFT JOIN t_store_size n ON m.masterpkid=n.pkid 
  WHERE a.visible='YES' AND b.visible='YES' AND c.visible='YES' 
  AND a.catpkid = 5 
  GROUP BY a.pkid, b.subcattitle, c.largephotofilename,  d.title , f.title 
  ORDER BY a.createdatetime DESC
  </code></pre>
  <p><strong>SQL Query Result of above query that I wanted</strong></p>
  <pre><code>pkid    catpkid subcatpkid  title       description     createdatetime          visible     listprice   ourprice    memberprice     subcattitle largephotofilename  cattitle    colortitle  sizetitle   
  132     5       118         Title01     Desc01          2020-07-15 14:44:51     YES         1599.00     570.00      470.00          SubCat01    image001.jpeg       cat001      Gray        L
  135     5       118         Title02     Desc02          2020-07-15 16:26:52     YES         1599.00     570.00      470.00          SubCat01    image002.jpeg       cat001      Pink        L
  </code></pre>
  <p>But now, when there is a product with different color and same size then again duplicate products are displaying in SQL result like below.</p>
  <p><strong>SQL Query Result With different colors and same size</strong></p>
  <pre><code>pkid    catpkid subcatpkid  title       description     createdatetime          visible     listprice   ourprice    memberprice     subcattitle largephotofilename  cattitle    colortitle  sizetitle   
  76      3       101         Title76     Desc76          2020-07-15 14:44:51     YES         1599.00     570.00      470.00          SubCat101   image076.jpeg       cat003      Red         FREESIZE
  76      3       101         Title76     Desc76          2020-07-15 16:26:52     YES         1599.00     570.00      470.00          SubCat101   image076.jpeg       cat003      Maroon      FREESIZE
  </code></pre>
  <p>Now I want to make so only first product with same pkid and size should display in SQL result. Currently they are displaying as 2 different products because they have same pkid and size but different colors.</p>
  <p>Still I will need above query where only first product with same pkid and color is displaying in SQL result.</p>
  <p>So I want to make so query should work in both cases.</p>
  <p>Thank you,</p>