Ver Mensaje Individual
  #5 (permalink)  
Antiguo 08/04/2009, 18:40
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: Actualizar campo de varios registros tomando valor de otro campo

Código mysql:
Ver original
  1. mysql> create table tabla_concat(campo1 text, campo2 text);
  2. Query OK, 0 rows affected (0.01 sec)
  3.  
  4. mysql> insert into tabla_concat (campo1) values('texto1');
  5. Query OK, 1 row affected (0.00 sec)
  6.  
  7. mysql> insert into tabla_concat (campo1) values('texto2');
  8. Query OK, 1 row affected (0.00 sec)
  9.  
  10. mysql> insert into tabla_concat (campo1) values('texto3');
  11. Query OK, 1 row affected (0.00 sec)
  12.  
  13. mysql> insert into tabla_concat (campo1) values('texto4');
  14. Query OK, 1 row affected (0.00 sec)
  15.  
  16. mysql> update tabla_concat set campo2=concat('cadena_fija ',campo1);
  17. Query OK, 4 rows affected (0.00 sec)
  18. Rows matched: 4  Changed: 4  Warnings: 0
  19.  
  20. mysql> select *from tabla_concat;
  21. +--------+--------------------+
  22. | campo1 | campo2             |
  23. +--------+--------------------+
  24. | texto1 | cadena_fija texto1 |
  25. | texto2 | cadena_fija texto2 |
  26. | texto3 | cadena_fija texto3 |
  27. | texto4 | cadena_fija texto4 |
  28. +--------+--------------------+
  29. 4 rows in set (0.00 sec)
  30.  
  31. mysql>

Tal vez con un ejemplo lo veas mejor.
__________________
Without data, You are another person with an opinion.
W. Edwads Deming