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 我的数字生活论坛 .



5 Responses to “How to Find and Replace Text in MySQL Database using SQL” 5回应“如何查找和替换文本在MySQL数据库中使用SQL ”

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

    Thanks a lot!感谢了很多! You’ve saved my life!您保存了我的生命!

  2. yourtronica
    May 11th, 2007 10:38 2007年5月11日10时38分
    2

    Thanks for the help!感谢您的帮助!

  3. Joost joost
    May 16th, 2007 07:24 2007年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月1日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!!感谢,这是非常有帮助!

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> 您可以使用这些标签:的<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <删除日期时间= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅无评论


Custom Search

New Articles新的条款,

Incoming Search Terms for the Article传入的搜索条件文章

mysql replace MySQL的取代 - - sql replace 的SQL取代 - - replace mysql 取代的MySQL - - mysql find and replace MySQL的查找和替换 - - sql replace command 取代的SQL命令 - - Mysql find replace MySQL中找到取代 - - sql find replace 的SQL找到取代 - - mysql string replace MySQL的字符串取代 - - mysql replace string MySQL的替换字符串 - - mysql replace text MySQL的替换文字 - - SQL replace text 的SQL取代文字 - - REPLACE SQL 取代的SQL - - MySQL replace function MySQL的Replace函数 - - sql search and replace 的SQL的搜索和替换 - - mysql search and replace MySQL的搜索和替换 - - sql find and replace 的SQL查找和替换 - - mySQL search replace MySQL的搜索取代 - - REPLACE IN MYSQL 取代在MySQL - - sql replace string 的SQL替换字符串 - - sql replace function 取代的SQL功能 - - mysql replace syntax MySQL的替代语法 - - mysql replace MySQL的取代 - - find and replace in sql 查找和替换在SQL - - replace in sql 取代在SQL - - find and replace sql 查找和替换的SQL - - mysql replace example MySQL的取代,例如 - - sql string replace SQL字符串取代 - - find replace mysql 找到取代的MySQL - - find replace sql 找到取代的SQL - - find and replace mysql 查找和替换的MySQL - - sql replace mysql MySQL中的SQL取代 - - REPLACE command in sql 取代命令在SQL - - SQL replace 的SQL取代 - - sql replace syntax 取代的SQL语法 - - replace sql command 取代SQL命令 - - replace text mysql 替换文字的MySQL - - mysql replace command MySQL的取代命令 - - mysql text replace MySQL的文本取代 - - find and replace SQL query 查找和替换SQL查询 - - replace text sql 替换文字的SQL - - MySQL Replace() MySQL的取代( ) - - search and replace mysql 搜索和替换的MySQL - - search replace mysql 搜索取代的MySQL - - mysql sql REPLACE MySQL中的SQL取代 - - mysql search and replace text MySQL的搜索和替换文本 - - mysql find MySQL的寻找 - - string replace mysql 字符串替换的MySQL - - mysql replace sql MySQL的取代的SQL - - MySQL REPLACE statement MySQL的取代声明 - - sql replace all 更换所有的SQL - - all 全部 - - mysql update replace text MySQL的更新替换文字 - - REPLACE function sql Replace函数的SQL - - sql + replace 的SQL +取代 - - replace text in mysql 取代文字在MySQL - - find replace in sql 找到取代在SQL - - mysql replace string function MySQL的替换字符串功能 - - string replace SQL 字符串替换的SQL - - sql replace examples 的SQL取代的例子 - - replace function in sql Replace函数在SQL - - sql search replace 的SQL搜索取代 - - sql replace example 的SQL取代,例如 - - find and replace in mysql 查找和替换在MySQL - - sql command replace SQL命令取代 - - search and replace in mysql 搜索和替换在MySQL - - mysql replace text MySQL的替换文字 - - mysql replace table MySQL的取代表 - - sql text replace 的SQL的文本取代 - - replace text in SQL 取代文字在SQL - - replace command sql 取代命令的SQL - - sql replace statement 取代的SQL声明 - - sql find text 的SQL查找文本 - - replace string sql 取代字串的SQL - - mysql + replace MySQL的+取代 - - mysql text search and replace MySQL的文本搜索和替换 - -