title: Issue using MIN() in mysql query
body: <p>I made the following query that get the <code>MIN(id)</code> of duplicate <code>path</code> values in the table <code>movies</code>:</p>
  
  <pre><code>SELECT m.id, m.user_id , m.path
  FROM movies m
    INNER JOIN (
                 SELECT Min(id) as movie_id, path,  COUNT(*)
                 FROM movies
                 WHERE importer LIKE '%AS%'
                 GROUP BY  path
                 HAVING COUNT(*) &gt; 1) temp
      ON  temp.path = p.path
          AND temp.movie_id = m.id
          AND importer LIKE '%AS%'
  </code></pre>
  
  <p>I got this result:</p>
  
  <pre><code>  id       | user_id |     path    | 
  ­­­­­­­­­­­­------------------------------------
   2         | 1234    |     XXXX    |  
   8         | 4231    |     BBBB    | 
  </code></pre>
  
  <p>The problem is that I have another movie with the same path but dont appear because the <code>MIN()</code> and the <code>GROUP BY path</code></p>
  
  <p>I want to group the path but dont exlude the other path because I do <code>MIN(id)</code></p>
  
  <p>This is the expected result:</p>
  
  <pre><code>  id       | user_id |     path    | 
  ­­­­­­­­­­­­------------------------------------
   2         | 1234    |     XXXX    |  
   8         | 4231    |     BBBB    | 
   5         | 3421    |     BBBB    | 
  </code></pre>
  
  <p>What Im doing wrong?</p>
  
  <p><code>@Tim Biegeleisen</code></p>
  
  <p>The problem is with that query I obtain duplicated paths with same user_id : </p>
  
  <pre><code>  id       | user_id |     path    | 
  ­­­­­­­­­­­­------------------------------------
    3523        12287         asd
    3524        12287         asd
    3525        12287         asd
  </code></pre>
  
  <p>I should obtain the min id for each grouped path.</p>