title: Multi column distinct in mysql
body: <pre><code>| one | two |
  -------------
  | A   | 1   |
  | A   | 2   |
  | B   | 1   |
  | B   | 3   |
  | C   | 1   |
  | C   | 4   |
  </code></pre>
  
  <p>I would like to get no repeats in any column in a query, so the standard 
  <code>SELECT DISTINCT one,two FROM table;</code>
  or <code>SELECT * FROM table GROUP BY one,two;</code> doesn't quite work, because it looks for distinct in all rows, which in this case would return all 6 rows.</p>
  
  <p>Ideally, I am looking for:</p>
  
  <pre><code>| one | two |
  -------------
  | A   | 1   |
  | B   | 3   |
  | C   | 4   |
  </code></pre>
  
  <p>In PHP (etc.), I would just do this with an array for each column, and if any column has been used before then skip the row.  I am not sure how to implement that in MySQL, though.</p>
  
  <p><code>SELECT * FROM (SELECT * FROM table GROUP BY one) GROUP BY two</code>- almost works. but because the outer query doesn't see all the alternatives, it will miss valid options, i.e. the inner will collapse to A,B,C but could well pick <strong>all</strong> 1s for column two, which would mean the second GROUP BY would then collapse it own to 1 row!</p>
  
  <p>I know the order of duplication checking will have an effect on the exact rows returned -- not worried about that -- I just want a good cross section of rows with minimal similar rows.</p>