title: How to keep one row for each unique column value after groupby in MySQL?
body: <p>I have a column of ids and a column of emails. I would like to group by id and only keep rows with distinct emails (it can be any row). For example:</p>
  
  <pre><code>+-------------------------------+
  |    Id          Email          |
  +-------------------------------+
  |    1         email1           |
  |    1         email2           |
  |    1         email1           |
  |    2         email3           |
  |    2         email3           |
  |    3         email4           |
  |    3         email4           |
  +-------------------------------+
  </code></pre>
  
  <p>The final output would be:</p>
  
  <pre><code>+---------------------------+
  | Id            Email       |
  +---------------------------+
  | 1        email1           |
  | 1        email2           |
  | 2        email3           |
  | 3        email4           |
  +---------------------------+
  </code></pre>
  
  <p>The idea is something like</p>
  
  <pre><code>SELECT * FROM table
  GROUP BY Id
  HAVING DISTINCT(email)
  </code></pre>
  
  <p>but the syntax is not correct.</p>
  
  <p>Any help would be appreciated. Thank you!</p>