How to Find and Replace Text in MySQL Database using SQL Kaip rasti ir pakeisti tekstą ir MySQL duomenų bazė 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 duomenų bazė yra patogu ir paprasta string funkcija REPLACE (), kuri leidžia lentelės duomenų atitikimo eilutę (from_string) turi būti pakeistas new 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. Tai naudinga, jei yra poreikis paieška ir pakeisti teksto eilutę, kuri veikia daug įrašų arba eilučių, kaip antai pakeisti įmonės pavadinimą, pašto kodas, adresas ar rašybos klaida.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) Iš REPLACE sintaksė REPLACE (text_string, from_string, to_string)
MySQL reference MySQL nuorodos 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. aprašoma pakeisti taip, kad funkcija grąžina eilutę text_string su visais string from_string pakeičiama string to_string, kur atitikimas yra jautri ieškant from_string įvykių. text_string can be retrieved from the a field in the database table too. text_string galima atsisiųsti iš lauko duomenų bazės lentelę per. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. Dauguma SQL komandos gali būti REPLACE () funkciją, ypač select ir atnaujinti manipuliacijos pareiškimą.
For example: Pavyzdžiui
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string'); atnaujinti table_name nustatyti FIELD_NAME = Replace (FIELD_NAME, "Rasti šią string ',' pakeisti rasti eilutę pagal šią eilutę ');
update client_table set company_name = replace(company_name, 'Old Company', 'New Company') atnaujinti client_table nustatyti company_name = Replace (company_name, 'senosios bendrovės', 'Naujos Bendrovė ")
The above statement will replace all instances of 'Old Company' to 'New Company' in the field of company_name of client_table table. Aukščiau pareiškimas bus pakeisti visi "instances senosios bendrovės" į "Naujosios Company" į company_name iš client_table stalo srityje.
Another example: Kitas pavyzdys:
SELECT REPLACE('www.mysql.com', 'w', 'Ww'); PASIRINKITE REPLACE ( "www.mysql.com ',' w ',' ww ');
Above statement will return 'WwWwWw.mysql.com' as result. Virš pareiškimas sugrįš "WwWwWw.mysql.com" kaip rezultatas.
IMPORTANT : The page is machine translated and provided "as is" without warranty. DĖMESIO: Šis puslapis yra mašina išvertė ir pateikiama "kaip yra" be garantijų. Machine translation may be difficult to understand. Automatinis vertimas gali būti sunku suprasti. Please refer to Remkitės original English article originalas anglų straipsnis whenever possible. jei įmanoma.
Related Articles Susiję straipsniai
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Pašalinti ar Trim Pirma ar pastaruosius Veikėjai MySQL duomenų bazę su SQL
- Check and Optimize MySQL Database Automatically with Crontab/Cron Patikrinti ir optimizuoti MySQL duomenų bazė automatiškai crontab / cron
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): BLOB / skilties Naudojama Pagrindinės Specifikacija be rakto žodžio ilgis
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL Database Performance Tuning Best Practices Video Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Enable Logging lėtai užklausų (Slow Užklausa log) ir MySQL duomenų bazė
- Change and Reset MySQL root Password Kaitos ir naujo MySQL root Password
- Replace Notepad with Another Text Editor (eg. Notepad2 and Notepad++) in Vista Pakeisti Užrašų kitu tekstu redaktoriumi (pvz. Notepad2 ir Notepad + +) "Vista"
- Download File Content Replacer to Search and Replace Text in Multiple Files Download File Content Replacer į paiešką ir pakeisti tekstą keletą failų
- Using PHP-MySQL Persistent Connections to Run WordPress Blog Naudojant PHP, MySQL Nuolatiniai ryšiai Vykdyti WordPress blog
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Kaip Backup and Restore (eksportas ir importas) MySQL duomenų bazės Susipažinkite










































October 28th, 2009 09:00 28 spalis 2009 09:00
I am looking for a way to do this globally accross a whole database. Aš ieškau būdų tai padaryti visame pasaulyje per visą duomenų bazę.
October 20th, 2009 20:28 20 spalis 2009 20:28
Doesn't work at all for replacing web addresses within a database. Neveikia ne visos keičia interneto adresus per duomenų bazę.
September 30th, 2009 15:26 30 rugsėjis 2009 15:26
Wanted to use REPLACE command to use for a column of a table…and this helped me…thanks Ieško naudoti REPLACE komandą naudoti iš lentelės stulpelį ... ir tai padėjo man ... Ačiū