Home > Database > Mysql Tutorial > mysql 如何替换某字段值的部分内容

mysql 如何替换某字段值的部分内容

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 09:57:06
Original
1372 people have browsed it

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

<code class="language-sql">UPDATE 表名 SET 字段名= REPLACE( 替换前的字段值, '替换前关键字', '替换后关键字' ) WHERE 字段名 REGEXP "替换前的字段值"; </code>
Copy after login

 

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

<code class="language-sql">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 ); </code>
Copy after login

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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template