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