Select all columns with GROUP BY one column
<p>I have this table:</p>

<pre><code>+----+-----+----------+
| id | name| key      |
+----+-----+----------+
| 1  | foo |111000    |
| 2  | bar |111000    |
| 3  | foo |000111    |
+----+-----+----------+
</code></pre>

<p>Is there a way to group by the key to get this result?</p>

<pre><code>+----+-----+----------+
| id | name| key      |
+----+-----+----------+
| 2  | bar |111000    |
| 3  | foo |000111    |
+----+-----+----------+
</code></pre>

<p>Or this result:</p>

<pre><code>+----+-----+----------+
| id | name| key      |
+----+-----+----------+
| 1  | foo |111000    |
| 3  | foo |000111    |
+----+-----+----------+
</code></pre>

<p>If I use this query:</p>

<pre><code>SELECT * FROM sch.mytable GROUP BY(key);
</code></pre>

<p>This is not correct I know that, because I should group by all the columns that I need to show.</p>

<p>Is there a solution for this problem?</p>