How to Find and Replace Text in MySQL Database using SQL Cómo buscar y reemplazar texto en la base de datos MySQL usando SQL
MySQL database has a handy and simple string function REPLACE() that allows table data with the matching string (from_string) to be replaced by new string (to_string). Base de datos MySQL cuenta con un práctico y sencillo cadena función REPLACE () que permite que los datos de la tabla con la correspondiente cadena (from_string) para ser sustituidas por nuevas cadenas (to_string). This is useful if there is need to search and replace a text string which affects many records or rows, such as change of company name, postcode, URL or spelling mistake. Esto es útil si hay necesidad de buscar y reemplazar una cadena de texto que afecta a muchos registros o filas, como el cambio de nombre de la empresa, código postal, URL o error de ortografía.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) La sintaxis de REPLACE se REPLACE (text_string, from_string, to_string)
MySQL reference MySQL referencia describes REPLACE as function that returns the string text_string with all occurrences of the string from_string replaced by the string to_string, where matching is case-sensitive when searching for from_string. REPLACE describe como la función que devuelve la cadena text_string con todas las ocurrencias de la cadena from_string sustituye por la cadena to_string, cuando se pongan en venta se distingue entre mayúsculas y minúsculas al buscar from_string. text_string can be retrieved from the a field in the database table too. text_string puede obtenerse en el un campo en la tabla de base de datos. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. La mayoría de comandos SQL puede REPLACE (), especialmente SELECT y UPDATE manipulación declaración.
For example: Por ejemplo:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’); actualización TABLE_NAME conjunto FIELD_NAME = sustituir (FIELD_NAME, 'encontrar esta cadena »,« sustituir encontrado cadena con esta cadena');
update client_table set company_name = replace(company_name, ‘Old Company’, ‘New Company’) actualización client_table conjunto company_name = sustituir (company_name, «antigua empresa», «Nueva Empresa»)
The above statement will replace all instances of ‘Old Company’ to ‘New Company’ in the field of company_name of client_table table. La declaración anterior sustituirá a todos los casos de «antigua empresa» a «Nueva Empresa» en el ámbito de company_name de client_table mesa.
Another example: Otro ejemplo:
SELECT REPLACE(’www.mysql.com’, ‘w’, ‘Ww’); SELECT REPLACE ( 'www.mysql.com', 'w', 'Ww');
Above statement will return ‘WwWwWw.mysql.com’ as result. Por encima de declaración retorno »WwWwWw.mysql.com 'como resultado.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Se trata de una máquina que traduzca la página se proporciona "tal cual" sin garantía. Machine translation may be difficult to understand. La traducción automática puede resultar difícil de entender. Please refer to Por favor, consulte original English article artículo original Inglés whenever possible. siempre que sea posible.
Share and contribute or get technical support and help at Compartir y contribuir o recibir apoyo técnico y ayudar a My Digital Life Forums Mi vida digital Foros .
Related Articles Artículos relacionados
- How to Move WordPress Blog to New Domain or Location Cómo pasar a WordPress blog nuevo dominio o ubicación
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Eliminar o Trim primera o la última caracteres en la base de datos MySQL con SQL
- Change or Set MySQL Long Query Time Value for log-slow-queries Modificar o establecer a largo MySQL Query Time Value for log-slow-queries
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Como copia de seguridad y restaurar (exportaciones e importaciones) Bases de datos MySQL Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Habilitar registro de consultas Baja (Baja Query Log) en la base de datos MySQL
- WordPress MySQL SQL Query Error in WPDB Class WordPress MySQL consulta SQL Error en la clase WPDB
- MySQL Database Performance Tuning Best Practices Video Tutorial Base de datos MySQL para ajustar el rendimiento de Prácticas Recomendadas de vídeo tutorial
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Instalar Web Server en Windows XP con Apache 2, PHP5 y MySQL4 - Parte 4
- Change and Reset MySQL root Password Cambio y MySQL Restablecer contraseña de root
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): BLOB / TEXTO Columna Utilizado en clave Especificación Sin Key Largo






May 4th, 2007 05:48 4 de mayo, 2007 05:48
Thanks a lot! ¡Muchas gracias! You’ve saved my life! Usted ha salvado mi vida!
May 11th, 2007 10:38 Mayo 11, 2007 10:38
Thanks for the help! Gracias por la ayuda!
May 16th, 2007 07:24 16 de mayo de 2007 07:24
Excellent, just what I needed. Excelente, justo lo que necesitaba. Thanks! Gracias!
October 1st, 2007 18:23 1 de octubre de 2007 18:23
[...] The guide uses SQL statements based on MySQL replace() function to modify the database. [...] La guía utiliza comandos SQL sobre la base de sustituir MySQL () para modificar la base de datos. To run SQL queries, login to MySQL database that houses WordPress tables [...] Para ejecutar consultas SQL, acceso a base de datos MySQL que alberga los cuadros de WordPress [...]
June 4th, 2008 15:43 4 de Junio, 2008 15:43
thanks, this is very helpful!! gracias, esto es muy útil!