How to Find and Replace Text in MySQL Database using SQL Kā lai atrastu un aizstātu tekstu ar MySQL datu bāzi, izmantojot 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 datubāze ir ērts un vienkāršs string funkcija REPLACE (), kas ļauj tabulas datus ar atbilstības string (from_string), ko aizstāj ar jaunu 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. Tas ir noderīgi, ja ir nepieciešams, lai meklētu un aizvietotu teksta virkne, kas skar daudzus ierakstus vai rindas, piemēram, pārmaiņas uzņēmuma nosaukums, pasta indekss, URL vai pareizrakstības kļūda.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) No REPLACE sintakse ir REPLACE (text_string, from_string, to_string)
MySQL reference MySQL atsauces 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. apraksta REPLACE kā funkcija, kas atgriež virkni text_string ar visu stīgu from_string aizstāj ar string to_string, ja saskaņošana ir reģistrjutīga, meklējot from_string notikumi. text_string can be retrieved from the a field in the database table too. text_string var iegūt no lauka datu bāzes tabulā too. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. Lielākā daļa SQL komanda var tikt REPLACE () funkcija, it īpaši SELECT un UPDATE manipulācijas paziņojumu.
For example: For example:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string'); update TABLE_NAME kas FIELD_NAME = REPLACE (FIELD_NAME "atrast šajā string", "aizstāj konstatēja virkni ar šo string ');
update client_table set company_name = replace(company_name, 'Old Company', 'New Company') update client_table kas company_name = REPLACE (company_name "Old Company", "New Company")
The above statement will replace all instances of 'Old Company' to 'New Company' in the field of company_name of client_table table. Iepriekš minētais apgalvojums aizstās visus "gadījumiem Old Company" ar "Jaunā Company" šajā jomā company_name no client_table tabulā.
Another example: Vēl viens piemērs:
SELECT REPLACE('www.mysql.com', 'w', 'Ww'); SELECT REPLACE ( 'www.mysql.com "," w "," WW ");
Above statement will return 'WwWwWw.mysql.com' as result. Iepriekš minētais apgalvojums būs atgriešanās "WwWwWw.mysql.com" kā rezultāts.
IMPORTANT : The page is machine translated and provided "as is" without warranty. SVARĪGI: lapa mašīna iztulkot un pasniegts tàds, "kàds tas ir" bez garantijas. Machine translation may be difficult to understand. Mašīntulkošanas var būt grūti saprast. Please refer to Lūdzu, skatiet original English article oriģināls angļu rakstu whenever possible. kad vien iespējams.
Related Articles Saistītie raksti
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Noņemt vai Trim Pirmā vai pēdējo rakstzīmes MySQL datu bāze ar SQL
- Check and Optimize MySQL Database Automatically with Crontab/Cron Pārbaude un pilnveidošana MySQL Database automātiski ar Crontabula / Cron
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): BLOBQIBaseResult / teksta slejas Izmantots Key Specifikācija Without Key Length
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL Database Performance Tuning Paraugprakses Video Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Enable reģistrācija Slow Queries (Slow Query Ieiet) in MySQL Database
- Change and Reset MySQL root Password Pārmaiņas un Reset MySQL root paroli
- Replace Notepad with Another Text Editor (eg. Notepad2 and Notepad++) in Vista Aizvietot Notepad ar citu teksta redaktoru (piemēram, Notepad2 un Notepad + +) in Vista
- Download File Content Replacer to Search and Replace Text in Multiple Files Download File Content aizstājējbarībā to Search and Replace Teksts Multiple Files
- Using PHP-MySQL Persistent Connections to Run WordPress Blog Izmantojot PHP, MySQL noturīgiem Savienojumi, lai palaistu WordPress Blog
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Kā Rezerves kopēšanas un atjaunošanas (Export un Import) MySQL Databases Tutorial










































October 28th, 2009 09:00 28 oktobris 2009 09:00
I am looking for a way to do this globally accross a whole database. Es meklēju veids, kā to globāli pāri visa datubāze.
October 20th, 2009 20:28 20 oktobris 2009 20:28
Doesn't work at all for replacing web addresses within a database. Nedarbojas visos nomaiņai Web adreses, kas datu bāzē.
September 30th, 2009 15:26 30 septembris 2009 15:26
Wanted to use REPLACE command to use for a column of a table…and this helped me…thanks Gribēja izmantot REPLACE komanda izmantot kolonnas galda ... un tas palīdzēja man ... paldies