MySQL Character replacement command summary

Source: Internet
Author: User

UPDATE Table name SET Specifies field = replace (specify field, ' String to replace ', ' desired string ') WHERE condition; Delete space used today

Example one:

The code is as follows Copy Code

UPDATE ' Qlj_joke ' SET content = replace (content, '   ', ');

Case TWO:

Replace "Pjblog" in the "post_content" field of "Wp_posts" with "WordPress"

The code is as follows Copy Code

Update wp_posts Set Post_content=replace (post_content, ' pjblog ', ' WordPress ')

Example three:

Replace "Pjblog" in the "comment_content" field of "Wp_comments" with "WordPress"

Update wp_comments Set Comment_content=replace (comment_content, ' pjblog ', ' WordPress ')
After executing this code, you will be prompted how many pieces have been replaced:

Example Four

Increase the contents of the field according to the condition, such as adding TMP to the contents of the Logical_name field of the File_number=1 record, followed by the end

The code is as follows Copy Code

Update backupfile set Logical_name=replace (logical_name,logical_name, ' tmp ' +logical_name+ ' End ') where file_number=1

Example five replace into

REPLACE into Fanwe_order (ID,SN) VALUES (' 33 ', ' test replace into use ') Result: number of affected rows:

2

SELECT * from Fanwe_order WHERE sn= ' test replace into use '
Result: A line of records was detected

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.