How to Find and Replace Text in MySQL Database using SQL Ako nájsť a nahradiť text v MySQL databáze pomocou 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). Databáza MySQL je šikovný a jednoduchý reťazec funkcie REPLACE (), ktorá umožňuje dáta tabuľky s zodpovedajúci reťazec (from_string), ktoré majú byť nahradené novými 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. To je užitočné v prípade, že je potrebné hľadať a nahradiť textový reťazec, ktorý ovplyvňuje veľa záznamov alebo riadkov, ako je napríklad zmena názvu spoločnosti, PSČ, URL alebo pravopisné chyby.
The syntax of REPLACE is REPLACE(text_string, from_string, to_string) Syntax je REPLACE REPLACE (text_string, from_string, to_string)
MySQL reference MySQL referencie 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 opisuje ako funkcia, ktorá vráti reťazec text_string všetky výskyty reťazca from_string nahrádza reťazec to_string, kde zhoda je case-sensitive pri vyhľadávania from_string. text_string can be retrieved from the a field in the database table too. text_string možno získať z poľa v databázovej tabuľke príliš. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement. Väčšina môže byť SQL príkaz REPLACE () funkcie, a to najmä SELECT a UPDATE manipulácia vyhlásenia.
For example: Napríklad:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'find this string', 'replace found string with this string'); Aktualizácia TABLE_NAME nastaviť field_name = replace (field_name, 'nájsť tento reťazec', 'nájdených nahradiť reťazec s týmto string');
update client_table set company_name = replace(company_name, 'Old Company', 'New Company') Aktualizácia client_table nastaviť company_name = replace (company_name, 'Staré 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. Vyššie uvedené tvrdenie nahradí všetky výskyty 'Staré Company' na 'New Company' v oblasti company_name na client_table tabuľky.
Another example: Iný príklad:
SELECT REPLACE('www.mysql.com', 'w', 'Ww'); SELECT REPLACE ( 'www.mysql.com', 'w', 'Ww');
Above statement will return 'WwWwWw.mysql.com' as result. Vyššie uvedené tvrdenie sa vráti 'WwWwWw.mysql.com' ako výsledok.
IMPORTANT : The page is machine translated and provided "as is" without warranty. Upozornenie: stránka je stroje preložené a za predpokladu, "ako je" bez záruky. Machine translation may be difficult to understand. Strojový preklad môže byť ťažké pochopiť. Please refer to Nájdete na original English article originál Anglicky artikl whenever possible. ak je to možné.
Related Articles Súvisiace články
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Odstránenie alebo Trim prvý alebo posledný niekoľko znakov v MySQL databáze s SQL
- Check and Optimize MySQL Database Automatically with Crontab/Cron Skontrolovať a Optimalizácia MySQL databázu automaticky s crontab / Cron
- MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Dlh 1170 (42000): BLOB / TEXT stĺpca Používa sa v Key Špecifikácie Bez jeden Identifikovať Dĺžka
- MySQL Database Performance Tuning Best Practices Video Tutorial Databáza MySQL Performance Tuning Best Practices Video tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Povoliť Logovanie dotazov Slow (pomalý dotazu Log) v MySQL databáze
- Change and Reset MySQL root Password Zmien a Reset MySQL kmeň slová Heslo
- Replace Notepad with Another Text Editor (eg. Notepad2 and Notepad++) in Vista Nahradiť Bankovka s Iný Textový editor (eg. Notepad2 a Bankovka + +) do Vista
- Download File Content Replacer to Search and Replace Text in Multiple Files Stiahnite si súbor Obsah Replacer na Vyhľadávanie a nahrádzanie textu vo viacerých súborov
- Using PHP-MySQL Persistent Connections to Run WordPress Blog PHP-MySQL trvalé pripojenie k Beh WordPress Blog
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Až k Zálohovať a navrátiť (Export a Import) MySQL Báza dát Učiteľský










































October 28th, 2009 09:00 28.říjen 2009 09:00
I am looking for a way to do this globally accross a whole database. Hľadám spôsob, ako to dosiahnuť globálne naprieč celou databáz.
October 20th, 2009 20:28 20.říjen 2009 20:28
Doesn't work at all for replacing web addresses within a database. Nefunguje vôbec pre nahradenie webovej adresy do databázy.
September 30th, 2009 15:26 30.září 2009 15:26
Wanted to use REPLACE command to use for a column of a table…and this helped me…thanks Chcel využiť REPLACE príkazu na použitie pre stĺpec tabuľky ... a to mi pomohlo ... vďaka