title: SQL Select/Join, LIMIT result to 1st entry per element in query list
body: <p>I have a query like so</p>
  
  <pre><code>Select * from tableA A 
  LEFT JOIN
  mydb.tableB B
  ON A.pk = B.tableA_pk 
  LEFT JOIN 
  mydb.tableC C    
  ON B.tableC_pk = C.pk
  WHERE C.PK  IN ('325','305', '322')
  ORDER BY A.pk desc;
  </code></pre>
  
  <p>This will return a result like so with potentially multiple rows for an entry where applicable</p>
  
  <pre><code>4, xxx, yyy, 325, 325, zzz &lt;&lt;&lt;&lt; most recent for this entry ( 'unique' key is tableC.pk, 325)
  3, aaa, bbb, 325, 325, eee &lt;&lt;&lt;&lt; next most recent 
  3, ccc, ddd, 322, 322, fff
  2, eee, fff, 305, 305, rrr 
  2, ggg, hhhh,322, 322, ttt
  1, iii, jjj, 325, 325, uuu &lt;&lt;&lt; oldest
  </code></pre>
  
  <p>Ideally i want the result to look like below, that is for each matching entry in the LIST ..IN ('325', '322') it should only return the most recent entry like below</p>
  
  <pre><code>4, xxx, yyy, 325, 325, zzz &lt;&lt;&lt;&lt; most recent
  3, ccc, ddd, 322, 322, fff
  2, eee, fff, 305, 305, rrr 
  </code></pre>
  
  <p>To explain further..</p>
  
  <pre><code>Select * from tableA A 
  LEFT JOIN
  mydb.tableB B
  ON A.pk = B.tableA_pk 
  LEFT JOIN 
  mydb.tableC C    
  ON B.tableC_pk = C.pk
  WHERE C.PK  IN ('325')
  ORDER BY A.pk desc;
  </code></pre>
  
  <p>I would get this</p>
  
  <pre><code>4, xxx, yyy, 325, 325, zzz &lt;&lt;&lt;&lt; most recent for this entry 
  3, aaa, bbb, 325, 325, eee &lt;&lt;&lt;&lt; next most recent 
  1, iii, jjj, 325, 325, uuu &lt;&lt;&lt; oldest
  </code></pre>
  
  <p>But I need this:</p>
  
  <pre><code>4, xxx, yyy, 325, 325, zzz &lt;&lt;&lt;&lt; most recent for this entry ( 'unique' key is tableC.pk)
  </code></pre>
  
  <p>I have tried LIMIT 1 (I'm using MySQL) like below but this limits to 1 for the total request not 1 per searched entry in my query list.</p>
  
  <pre><code>Select * from tableA A 
  LEFT JOIN
  mydb.tableB B
  ON A.pk = B.tableA_pk 
  LEFT JOIN 
  mydb.tableC C    
  ON B.tableC_pk = C.pk
  WHERE C.pk  IN ('325','305', '322')
  ORDER BY A.pk desc
  LIMIT 1;
  </code></pre>