Le perle di MySQL

November 12, 2008
By

Oggi ne ho scoperta un’altra:

SELECT Id,  Id2
FROM Tabella
GROUP BY Id

+----+------+
| Id |  Id2 |
+----+------+
|  4 |    1 | 
|  4 |    2 | 
|  5 |    1 | 
|  5 |    2 | 
|  7 |    1 | 
|  7 |    2 | 
+----+------+
6 rows in set (0.05 sec)

SELECT Id, GROUP_CONCAT( Id2)
FROM Tabella
GROUP BY Id


+----+------+
| Id | Id2  |
+----+------+
|  4 | 1,2  | 
|  5 | 1,2  | 
|  7 | 1,2  | 
+----+------+
3 rows in set (0.05 sec)

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.