How to Find and Replace Text in MySQL Database using SQL Як знайти і замінити текст у використанні бази даних MySQL, 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). Бази даних MySQL, має зручний і простий рядка функції REPLACE (), яка дозволяє з даними таблиці відповідності рядка (from_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. Це корисно, якщо є необхідність пошуку та заміни тексту рядок, яка зачіпає безліч записів або рядків, таких як зміна назви підприємства, поштовий індекс, URL або орфографічні помилки.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) Синтаксис REPLACE це замінити (text_string, from_string, to_string)
MySQL reference MySQL Reference 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 описується як функція, яка повертає рядок text_string всі входження рядка from_string замінені рядки to_string, де відповідні чутливе до регістру при пошуку from_string. text_string can be retrieved from the a field in the database table too. text_string може бути отриманий з поля в таблиці бази даних теж. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. Більшість SQL команди може бути REPLACE () функцію, особливо SELECT та UPDATE маніпуляції заявою.
For example: Наприклад:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string'); TABLE_NAME оновлений набір FIELD_NAME = Replace (FIELD_NAME "знайдіть цей рядок ',' замінити знайти рядок з цього рядка ');
update client_table set company_name = replace(company_name, 'Old Company', 'New Company') оновлена client_table company_name набір = Replace (company_name, 'стара компанія', 'Нова компанія')
The above statement will replace all instances of 'Old Company' to 'New Company' in the field of company_name of client_table table. Дана заява буде замінити всі примірники 'стара компанія' в 'Новій компанії "в області company_name client_table в таблиці.
Another example: Інший приклад:
SELECT REPLACE('www.mysql.com', 'w', 'Ww'); SELECT REPLACE ( 'www.mysql.com', 'W', 'Ww');
Above statement will return 'WwWwWw.mysql.com' as result. Над заявою поверне 'WwWwWw.mysql.com "як результат.
IMPORTANT : The page is machine translated and provided "as is" without warranty. ВАЖЛИВО: Сторінка машина переведена і надаються "як є" без гарантії. Machine translation may be difficult to understand. Машинний переклад може бути важким для розуміння. Please refer to Будь ласка, зверніться до original English article оригінальний англійська статтю whenever possible. коли це можливо.
Related Articles Статті за Темі
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Видаліть обрізки першого або останньої декілька символів в базі даних MySQL з SQL
- Check and Optimize MySQL Database Automatically with Crontab/Cron Перевірка та оптимізація баз даних MySQL автоматично з Crontab / Cron
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Помилка 1170 (42000): BLOB / TEXT стовпець, який використовується у визначенні ключа без вказання довжини ключа
- MySQL Database Performance Tuning Best Practices Video Tutorial База даних MySQL Performance Tuning Best Practices Video Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Включення ведення журналу повільних запитів (Журнал повільних запитів) в базі даних MySQL
- Change and Reset MySQL root Password Зміни та Скидання пароля MySQL
- Replace Notepad with Another Text Editor (eg. Notepad2 and Notepad++) in Vista Замініть Блокнот з іншому текстовому редакторі (наприклад Notepad2 і Notepad + +) в Перспектива
- Download File Content Replacer to Search and Replace Text in Multiple Files Завантажити вміст файлу Replacer пошук і заміна тексту в декількох файлах
- Using PHP-MySQL Persistent Connections to Run WordPress Blog Використання PHP-MySQL постійних з'єднань для запуску блог на WordPress
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial










































September 30th, 2009 15:26 30 Вересня 2009 15:26
Wanted to use REPLACE command to use for a column of a table…and this helped me…thanks Хотіли використовувати REPLACE команду використовувати для стовпців таблиці ... і це допомогло мені ... спасибо