title: How to use DISTINCT in WHERE CLAUSE to avoid repeated row returns
body: <p>The result of this SQL query should return a set of 6 rows.</p>
  
  <pre><code>SELECT baseFeeds.siteURL, feedFinishes.timeTaken, feedFinishes.timeSubmitted 
  FROM feedFinishes 
  LEFT OUTER JOIN baseFeeds 
  ON feedFinishes.GUID = baseFeeds.GUID 
  WHERE feedFinishes.nowDate = baseFeeds.nowDate 
  AND baseFeeds.siteURL LIKE '%www.example.com%'
  </code></pre>
  
  <p>Currently it returns 18 rows, the correct 6 rows are being repeated 3 times. I figure a solution to this is to have another WHERE clause something similar to:</p>
  
  <p><code>WHERE DISTINCT feedFinishes.ID</code></p>
  
  <p>After researching this I have tried:</p>
  
  <pre><code>SELECT baseFeeds.siteURL, feedFinishes.timeTaken, feedFinishes.timeSubmitted 
  FROM feedFinishes 
  JOIN baseFeeds 
  ON feedFinishes.GUID = baseFeeds.GUID 
  WHERE baseFeeds.siteURL LIKE '%www.example.com%' AND feedFinishes.ID in
       (SELECT ID FROM feedFinishes GROUP BY ID HAVING COUNT(ID)=1);
  </code></pre>
  
  <p>After the discussion found <a href="https://stackoverflow.com/questions/5610528/distinct-clause-with-where">here</a></p>
  
  <p>Alas, this still returns 18 rows. I believe the answer is similar to <a href="https://stackoverflow.com/questions/612231/how-can-i-select-rows-with-maxcolumn-value-distinct-by-another-column-in-sql">here</a></p>
  
  <p>Any advice would be appreciated.</p>