How to to combine rows where atleast one column has duplicate data in mysql
<p>I am trying to merge rows in mysql database if a key column has the same data for multiple rows. I just can't figure out a way to do this.</p>

<p>Here is the scenario:</p>

<pre><code>clm0 clm1 clm2 clm3
 1    aa   ab   ad
 2    cb   ac   af
 3    aa   ab   xx
 4    cb   ac   yy
</code></pre>

<p>Here the column I want to check is <code>clm2</code>. If <code>clm2</code> is common for any rows, I would like to merge the rows. First row doesn't matter. So it would become this:</p>

<pre><code> clm0 clm1 clm2  clm3
  1    aa   ab  ad, xx
  2    cb   ac  af, yy
</code></pre>

<p>So can anyone please help me out in this? I am trying to achieve this in python just FYI.</p>