How to Find and Replace Text in MySQL Database using SQL Como Localizar e substituir texto em SQL usando o MySQL Database
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). O MySQL tem um banco de dados acessível e simples string função REPLACE () que permite que os dados com a tabela de correspondência string (from_string), para ser substituída por nova string (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. Isso é útil se houver necessidade de pesquisa e de substituir uma cadeia de texto que afecta muitos registros ou linhas, tais como a mudança de nome da empresa, código postal, ou URL erro de ortografia.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) A sintaxe é de REPLACE REPLACE (text_string, from_string, to_string)
MySQL reference MySQL referência 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 descreve como função que retorna a string text_string com todas as ocorrências da string from_string substituída pela string to_string, onde correspondência é sensível a maiúsculas e minúsculas quando procurando por from_string. text_string can be retrieved from the a field in the database table too. text_string podem ser recuperadas a partir de um campo na tabela do banco de dados também. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. A maioria dos comandos SQL pode ser REPLACE (), SELECT e UPDATE especialmente manipulação declaração.
For example: Por exemplo:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’); atualização TABLE_NAME conjunto substituir FIELD_NAME = (FIELD_NAME ', localize a string', 'string substituir encontrado com essa string');
update client_table set company_name = replace(company_name, ‘Old Company’, ‘New Company’) atualização client_table conjunto company_name substituir = (company_name, 'Old Company "," Nova Empresa ")
The above statement will replace all instances of ‘Old Company’ to ‘New Company’ in the field of company_name of client_table table. A declaração acima irá substituir todas as instâncias de 'Old Company "para a" nova sociedade ", no domínio do company_name de client_table tabela.
Another example: Outro exemplo:
SELECT REPLACE(’www.mysql.com’, ‘w’, ‘Ww’); SELECT REPLACE ( 'www.mysql.com', 'w', 'WW');
Above statement will return ‘WwWwWw.mysql.com’ as result. Declaração acima irá retornar 'WwWwWw.mysql.com' como resultado.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Esta é uma página traduzida máquina que é fornecida "como está" sem garantia. Machine translation may be difficult to understand. A tradução automática pode ser difícil de compreender. Please refer to Por favor, consulte a original English article Inglês original article whenever possible. sempre que possível.
Share and contribute or get technical support and help at Compartilhe e contribuir ou obter suporte técnico e ajudar a My Digital Life Forums Minha vida digital Fóruns .
Related Articles Artigos relacionados
- How to Move WordPress Blog to New Domain or Location Como se deslocar para WordPress blog novo domínio ou local
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Remover ou Trim Primeiro ou últimos caracteres de Dados MySQL com SQL
- Change or Set MySQL Long Query Time Value for log-slow-queries Alterar ou definir o MySQL Query Long Time Valor para log-slow-queries
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Como a Backup e Restauração (de Importação e Exportação) Bancos de dados MySQL Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Ativar registro de Consultas Lento (Slow Query Log) no MySQL Database
- WordPress MySQL SQL Query Error in WPDB Class WordPress MySQL consulta SQL erro na classe WPDB
- MySQL Database Performance Tuning Best Practices Video Tutorial Banco de dados MySQL Performance Tuning melhores práticas vídeo tutorial
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Instalar Web Server no Windows XP com Apache2, PHP5 e MySQL4 - Parte 4
- Change and Reset MySQL root Password Mudança e Reset MySQL raiz Senha
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): BLOB / TEXT Coluna Utilizado em Key Especificação Sem uma chave Comprimento










May 4th, 2007 05:48 4 de maio de 2007 05:48
Thanks a lot! Thanks a lot! You’ve saved my life! Você salvou a minha vida!
May 11th, 2007 10:38 11 de maio de 2007 10:38
Thanks for the help! Obrigado pela ajuda!
May 16th, 2007 07:24 16 de maio de 2007 07:24
Excellent, just what I needed. Excelente, só o que eu precisava. Thanks! Obrigado!
October 1st, 2007 18:23 Outubro 1o, 2007 18:23
[...] The guide uses SQL statements based on MySQL replace() function to modify the database. [...] O guia utiliza instruções SQL baseado em MySQL substituir () função de modificar a base de dados. To run SQL queries, login to MySQL database that houses WordPress tables [...] Para executar consultas SQL, login de banco de dados MySQL que abriga WordPress tabelas [...]
June 4th, 2008 15:43 4 de junho de 2008 15:43
thanks, this is very helpful!! graças, este é muito útil!