title: How can I select only the first distinct match from a field in MySQL?
body: <p>How can I only return the first distinct match of a field in MySQL?</p>
  
  <p>My Table:</p>
  
  <pre><code>name     hash
  ----------------
  Anna     ABC
  Barb     DEF
  Charlie  GHI
  Anna     JKL
  Andrea   MNO
  </code></pre>
  
  <p>My Query (for <code>%An%</code>) :</p>
  
  <pre><code>SELECT DISTINCT(name) as name, hash FROM my_table WHERE name LIKE '%An%';
  </code></pre>
  
  <p>This returns:</p>
  
  <pre><code>name     hash
  ----------------
  Anna     ABC
  Anna     JKL
  Andrea   MNO
  </code></pre>
  
  <p>Instead of: <em>(the result I'm after)</em></p>
  
  <pre><code>name     hash
  ----------------
  Anna     ABC
  Andrea   MNO
  </code></pre>
  
  <p>How can I get only the first match of each distinct name?</p>
  
  <p>I want to return the first <code>Anna</code>, skip the second (and any subsequent matches), but still get <code>Andrea</code> (and any further distinct matches, like <code>Andrew</code> or <code>Anthony</code>).</p>