Home > Database > Mysql Tutorial > MySQL 替换某字段内部分内容的UPDATE语句_MySQL

MySQL 替换某字段内部分内容的UPDATE语句_MySQL

WBOY
Release: 2016-06-01 13:23:58
Original
989 people have browsed it

bitsCN.com 要替换某一个字段中的部分内容,可以用update 语句:

UPDATE 表名 SET 字段名= REPLACE( 替换前的字段值, '替换前关键字', '替换后关键字' ) WHERE 字段名 REGEXP "替换前的字段值";

比如替换标题里面的产品价格就是用这个方法

UPDATE dede_archives SET title= REPLACE( title, 155, 170 );
UPDATE dede_archives SET title= REPLACE( title, 180, 230 );
UPDATE dede_archives SET title= REPLACE( title, 270, 350 );
UPDATE dede_archives SET title= REPLACE( title, 210, 170 );
UPDATE dede_archives SET title= REPLACE( title, 155, 170 );
bitsCN.com

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template