Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/12/2009, 12:36
Avatar de huesos52
huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 15 años, 3 meses
Puntos: 360
Respuesta: Problema sin resolver.....

Aunque me parece que tienes problemas de diseño en tu tabla, esto es una solución a tu problema.

Código mysql:
Ver original
  1. mysql> select *from cliente;
  2. +------+-------+-------+-------+-------+-------+
  3. | id   | fono1 | fono2 | fono3 | fono4 | fono5 |
  4. +------+-------+-------+-------+-------+-------+
  5. |    1 |  1111 |  2222 |  NULL |  4444 |  5555 |
  6. |    2 |  1111 |  2222 |  NULL |  NULL |  NULL |
  7. |    3 |  NULL |  NULL |  NULL |  4444 |  NULL |
  8. |    4 |  NULL |  2222 |  3333 |  4444 |  5555 |
  9. +------+-------+-------+-------+-------+-------+
  10. 4 rows in set (0.00 sec)
  11.  
  12. mysql> select * from
  13.     -> (
  14.     -> select id,fono1 from cliente
  15.     -> union
  16.     -> select id,fono2 from cliente
  17.     -> union
  18.     -> select id,fono3 from cliente
  19.     -> union
  20.     -> select id,fono4 from cliente
  21.     -> union
  22.     -> select id,fono5 from cliente
  23.     -> order by id,fono1
  24.     -> )t1 where t1.fono1 is not null;
  25. +------+-------+
  26. | id   | fono1 |
  27. +------+-------+
  28. |    1 |  1111 |
  29. |    1 |  2222 |
  30. |    1 |  4444 |
  31. |    1 |  5555 |
  32. |    2 |  1111 |
  33. |    2 |  2222 |
  34. |    3 |  4444 |
  35. |    4 |  2222 |
  36. |    4 |  3333 |
  37. |    4 |  4444 |
  38. |    4 |  5555 |
  39. +------+-------+
  40. 11 rows in set (0.00 sec)
  41.  
  42. mysql>

asumo que los valores que no presentas son null en la tabla

saludos
__________________
Without data, You are another person with an opinion.
W. Edwads Deming