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數據庫有一個方便簡單的字符串函數取代( ) ,使表數據的匹配字符串( 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.這是非常有用的,如果有必要搜索和替換文字字串而影響到許多記錄或行,如變更公司名稱,郵政編碼,網址或拼寫錯誤。

The syntax of REPLACE is REPLACE(text_string, from_string, to_string)語法的接替是接替( text_string , from_string , to_string )

MySQL reference MySQL的參考 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.介紹了作為替代功能,返回字符串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命令可以接替( )函數,尤其是選擇和更新操縱發言。

For example:例如:

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);更新TABLE_NAME一套FIELD_NAME =取代( FIELD_NAME ,發現此字串' , '替換字符串發現此字串' ) ;

update client_table set company_name = replace(company_name, ‘Old Company’, ‘New Company’)更新client_table一套company_name =取代( 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’);選擇接替( ' www.mysql.com ' , '瓦特' , '二戰' ) ;

Above statement will return ‘WwWwWw.mysql.com’ as result.上述聲明將返回' WwWwWw.mysql.com '的結果。

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要說明:這是一台機器翻譯網頁這是“原樣”提供,無保修。 Machine translation may be difficult to understand.機器翻譯可能很難理解。 Please refer to請參閱 original English article英文原文的文章 whenever possible.只要有可能。

Share and contribute or get technical support and help at共享和貢獻或獲得技術支持和幫助 My Digital Life Forums 我的數字生活論壇 .



11 Responses to “How to Find and Replace Text in MySQL Database using SQL” 11日的答复“如何查找和替換文本在MySQL數據庫使用SQL ”

  1. masterik
    May 4th, 2007 05:48 2007年5月4日05:48
    1

    Thanks a lot!多謝! You’ve saved my life!您救了我的命!

  2. yourtronica
    May 11th, 2007 10:38 07年5月11號10:38
    2

    Thanks for the help!謝謝您的幫助!

  3. Joost Joost的
    May 16th, 2007 07:24 07年5月16號7點24分
    3

    Excellent, just what I needed.優秀,正是我需要的。 Thanks!謝謝!

  4. How to Move WordPress Blog to New Domain or Location » My Digital Life如何將WordPress的博客新域或位置»我的數字生活
    October 1st, 2007 18:23 2007年10月一日18:23
    4

    [...] The guide uses SQL statements based on MySQL replace() function to modify the database. [...]指南使用SQL語句MySQL的基礎上取代( )函數來修改數據庫。 To run SQL queries, login to MySQL database that houses WordPress tables [...]要運行SQL查詢,登錄到MySQL數據庫房屋WordPress的表格[...]

  5. Monica莫尼卡
    June 4th, 2008 15:43 2008年6月4日15:43
    5

    thanks, this is very helpful!!感謝,這是非常有益的!

  6. Tux Training » Blog Archive » How to Move WordPress Blog to New Domain or Location企鵝培訓» blog存檔»如何移動WordPress的博客新域或位置
    September 1st, 2008 01:48 08年9月1日1時48
    6 6日

    [...] The guide uses SQL statements based on MySQL replace() function to modify the database. [...]指南使用SQL語句MySQL的基礎上取代( )函數來修改數據庫。 To run SQL queries, login to MySQL database that houses WordPress tables [...]要運行SQL查詢,登錄到MySQL數據庫房屋WordPress的表格[...]

  7. sbsxrx
    September 10th, 2008 21:52 2008年9月十日21:52
    7 7日

    Algo k es puede resultar practico es cuando se necesita eliminar un caracter de una sere de registros es: k方塊算法以了解resultar practico方塊寬本身necesita eliminar取消字符的烏納塞雷德registros方塊:

    update tabla1 set campo1=replace(campo1,’8′,”);更新tabla1一套campo1 =取代( campo1 , '8 ',");

    esta sentencia eliminaria todos los 8 de la tabla: tabla1 del registro: campo1此sentencia eliminaria托多斯8日德拉塔夫拉: tabla1刪除註冊: campo1

    (NOTA: las comillas son todas simples). (注意:拉斯comillas兒子托達單純) 。

  8. martin馬丹
    October 9th, 2008 21:16 08年10月9日21:16
    8 8日

    nececito reemplazar un tag con todo su relleno, por ejemplo nececito reemplazar聯合國標記控制的TODO洙relleno ,房ejemplo
    update pagina_web.noticias set texto = replace(texto, “”>”,” ” )更新pagina_web.noticias一套texto =取代( texto , "">"," “ )

    por vacio!!!房間vacio ! como hago para estandalizarla y que encuetre todo lo que esta dentro de科莫hago第estandalizarla及活動encuetre你的TODO樂此迪登特魯德

  9. Tim蒂姆
    October 16th, 2008 01:00 2008年10月一十六日01:00
    9 9日

    For me this is only working on exact replaces.對於我來說,這只是工作的確切取代。 I could replace all entries that are exact the searchterm but i could replace parts of an entry.我可以取代所有項目,確切的searchterm ,但我可以取代部分的條目。

  10. Clifton Griffin | Replacing Text in a MySQL Table |克利夫頓格里芬|替換文字在一個MySQL表|
    October 21st, 2008 09:42 2008年10月21號09:42
    10 10個

    [...] quick Google search led me to this helpful page.  In short, I had to run the following: UPDATE wp_posts SET post_content = [...] [...]快速谷歌搜索使我這個有益的網頁。總之,我不得不執行下列:更新wp_posts集post_content = [...]

  11. Jack傑克
    November 29th, 2008 00:46 2008年11月29日00:46
    11 11日

    didn’t work for me…沒有工作的我...

Leave a Reply留下一個回复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用這些標籤: href="" title="">的<a <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> “刪除日期時間= “ ” “的<em> <i> <q cite=""> <strike>的<strong>

Subscribe to comments feature has been disabled. 訂閱評論功能已被禁用。 To receive notification of latest comments posted, subscribe to 收到通知的最新評論張貼,訂閱 My Digital Life Comments RSS feed 我國數字化生活的評論RSS種子 or register to receive 接收登記 new comments in daily email digest. 中新評論的電子郵件,每天消化。
Custom Search

New Articles新文章

Incoming Search Terms for the Article收到的搜索字詞的文章

mysql replace 數據庫取代 - - sql replace 數據庫取代 - - replace mysql 取代數據庫 - - mysql find and replace MySQL的查找和替換 - - sql replace command 數據庫替換命令 - - Mysql find replace 數據庫找到取代 - - sql find replace 數據庫找到取代 - - mysql string replace MySQL的字符串替換 - - mysql replace string 數據庫替換字符串 - - mysql replace text MySQL的替換文字 - - SQL replace text 替換文字的SQL - - REPLACE SQL 接替的SQL - - MySQL replace function MySQL的替換功能 - - sql search and replace 數據庫搜索和替換 - - mysql search and replace 數據庫搜索和替換 - - sql find and replace 數據庫查找和替換 - - mySQL search replace MySQL的搜尋取代 - - REPLACE IN MYSQL MySQL中取代 - - sql replace string 數據庫替換字符串 - - sql replace function 數據庫取代功能 - - mysql replace syntax MySQL的替代語法 - - mysql replace 數據庫取代 - - find and replace in sql 查找和替換在SQL - - replace in sql 在SQL取代 - - find and replace sql 查找和替換數據庫 - - mysql replace example 例如MySQL的取代 - - sql string replace SQL字符串替換 - - find replace mysql 找到取代數據庫 - - find replace sql 找到取代的SQL - - find and replace mysql 查找和替換數據庫 - - sql replace mysql 數據庫替代MySQL的 - - REPLACE command in sql 接替指揮在SQL - - SQL replace 數據庫取代 - - sql replace syntax 數據庫替代語法 - - replace sql command 取代SQL命令 - - replace text mysql 替換文字數據庫 - - mysql replace command 數據庫替換命令 - - mysql text replace MySQL的文字取代 - - find and replace SQL query 查找和替換SQL查詢 - - replace text sql 替換文字數據庫 - - MySQL Replace() MySQL的替換( ) - - search and replace mysql 搜索和替換數據庫 - - search replace mysql 搜尋取代數據庫 - - mysql sql REPLACE 數據庫的SQL接替 - - mysql search and replace text 數據庫搜索和替換文本 - - mysql find 數據庫找到 - - string replace mysql 字符串替換數據庫 - - mysql replace sql 取代的SQL數據庫 - - MySQL REPLACE statement MySQL的接替聲明 - - sql replace all 取代所有的SQL - - all 全部 - - mysql update replace text MySQL的更新替換文字 - - REPLACE function sql 接替功能的SQL - - sql + replace 數據庫+取代 - - replace text in mysql 替換文字的MySQL - - find replace in sql 找到取代在SQL - - mysql replace string function 數據庫替換字符串函數 - - string replace SQL 字符串替換的SQL - - sql replace examples 數據庫取代的例子 - - replace function in sql 取代功能在SQL - - sql search replace 數據庫搜索取代 - - sql replace example 例如數據庫取代 - - find and replace in mysql 查找和替換的MySQL - - sql command replace SQL命令取代 - - search and replace in mysql 搜索和替換的MySQL - - mysql replace text MySQL的替換文字 - - mysql replace table 數據庫取代表 - - sql text replace 熟悉的文字取代 - - replace text in SQL 替換文字在SQL - - replace command sql 替換命令的SQL - - sql replace statement 數據庫取代聲明 - - sql find text 數據庫找到文字 - - replace string sql 替換字符串的SQL - - mysql + replace 數據庫+取代 - - mysql text search and replace MySQL的全文搜索和替換 - -