How to use the REPLACE() function in MySQL

WBOY
Release: 2023-06-02 23:25:01
forward
2667 people have browsed it

REPLACE()

REPLACE(str,from_str,to_str)The function is used to replace all from_str in the string str with to_str and return the replaced string. For example:

SELECT REPLACE('MySQL字符串函数', '字符串', '日期') AS str1, REPLACE('MySQL字符串函数', '字符串', '') AS str2; str1 |str2 | ------------+---------+ MySQL日期函数|MySQL函数|
Copy after login

In addition,INSERT(str,pos,len,newstr)The function is used to insert the substring newstr after the specified position pos of the string str, replacing the subsequent len characters . For example:

SELECT INSERT('MySQL字符串函数', 6, 3, '日期') AS str; str | ------------+ MySQL日期函数|
Copy after login

The above is the detailed content of How to use the REPLACE() function in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!