Ver Mensaje Individual
  #10 (permalink)  
Antiguo 24/06/2009, 08:54
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: consulta para borrar solo letras de un campo y dejar solo numeros

Ahí si tendría problemas.

Cambia un poco la sentencia.

Código mysql:
Ver original
  1. mysql> select *from telefonos;
  2. +-----------+
  3. | telefono  |
  4. +-----------+
  5. | 8890204   |
  6. | 8890504   |
  7. | 8890514   |
  8. | 82114898u |
  9. | 82114898j |
  10. +-----------+
  11. 5 rows in set (0.00 sec)
  12.  
  13. mysql> update telefonos set telefono=if(ascii(right(telefono,1))<48 or ascii(right(telefono,1))>57,substring(telefono,1,length(telefono)-1),telefono);
  14. Query OK, 2 rows affected (0.00 sec)
  15. Rows matched: 5  Changed: 2  Warnings: 0
  16.  
  17. mysql> select *from telefonos;
  18. +----------+
  19. | telefono |
  20. +----------+
  21. | 8890204  |
  22. | 8890504  |
  23. | 8890514  |
  24. | 82114898 |
  25. | 82114898 |
  26. +----------+
  27. 5 rows in set (0.00 sec)
  28.  
  29. mysql>

Esta resuelve el problema.
__________________
Without data, You are another person with an opinion.
W. Edwads Deming