Pregunta: Como puedo agrupar en un solo registro todos los valores para un campo determinado?
Respuesta: Con la función
group_concat Ejemplo:
Código mysql:
Ver originalQuery OK, 0 rows affected (0.06 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
+----------+-------------+
| persona | deporte |
+----------+-------------+
| Daniel | Futbol |
| Daniel | Baloncesto |
| Daniel | valley ball |
| Juan | Tennis |
| Juan | Futbol |
| Santiago | Waterpolo |
| Santiago | Baloncesto |
+----------+-------------+
+----------+-----------------------------------+
| persona | deportes |
+----------+-----------------------------------+
| Daniel | Futbol - Baloncesto - valley ball |
| Juan | Tennis - Futbol |
| Santiago | Waterpolo - Baloncesto |
+----------+-----------------------------------+