title: Mysql merge rows
body: <p>I have this table:</p>
  
  <pre><code>ip   country
  
  1     A
  2     A
  3     B
  4     B
  4     B
  </code></pre>
  
  <p>I am trying to write a query, which will return something like:</p>
  
  <pre><code>A 1,2
  B 3,4
  </code></pre>
  
  <p>E.g. <code>SELECT * FROM table GROUP BY</code> country returns:</p>
  
  <pre><code>A 1
  B 3
  </code></pre>
  
  <p>But it's not the desired result.</p>
  
  <p>Ι can run this simple query: </p>
  
  <pre><code>SELECT * FROM table ORDER BY ip
  </code></pre>
  
  <p>and <strong>programmatically</strong> will write something like:</p>
  
  <pre><code>$c_ip=0;
  while($row=mysql_fetch_array($result,MYSQL_ASSOC)){
  if($row['ip'])!=$c_ip)
  {
  $c_ip=$row['ip'];
  //new line!!
  }else
  {
  //don't close &lt;tr&gt; code goes here
  }
  }
  </code></pre>