网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 58.241.198.160
Old 2013-05-09, 04:54 PM
超级女声 超级女声 is offline
初级会员
 
Join Date: 2006-04-05
Posts: 2
超级女声 正向着好的方向发展
Default 批量替换 MySQL 指定字段中的字符串

批量替换 MySQL 指定字段中的字符串是数据库应用中很常见的需求,但是有很多初学者在遇到这种需求时,通常都是用脚本来实现;其实,MySQL 内置的有批量替换语法,效率也会高很多;想了解具体方法,继续看下边内容吧!!!


批量替换的具体语法是
Code:
UPDATE 表名 SET 
指定字段 = replace(指定字段, '要替换的字符串', '想要的字符串') 
WHERE 条件;
如果你想把 article 表中 ID 小于5000的记录,content 字段中“解决”替换成“解放”,那么语法就是:

Code:
UPDATE article SET 
content = replace(content, '解决', '解放') 
WHERE ID<5000;
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
关于PHP中操作MySQL数据库的一些要注意的问题 smiling 代码交流 0 2006-12-15 07:22 PM
如何导入导出MySQL数据库 topvip 建站交流 0 2006-10-10 07:43 AM
使用XAMPP轻松建站(Linux版) smiling 服务器环境搭建 0 2006-05-13 04:01 AM
mysql安装与简单使用 sunshine 服务器环境搭建 0 2006-01-11 07:29 PM
winxp下安装全新的apache,php(5.0),mysql(5.0)... topvip 服务器环境搭建 0 2006-01-08 10:28 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:39 PM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.