网络营销电子商务研究中心  
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: 117.95.1.65
Old 2015-03-21, 07:45 PM
Kenton Kenton is offline
初级会员
 
Join Date: 2010-02-27
Posts: 1
Kenton 现在声名狼藉
Default mysql数据库删除包含指定字符的数据

mysql数据库删除包含指定字符的数据

主要在 WHERE 条件中使用 LIKE 操作符

1.查询post表中 title 字段包含<b></b>的数据

SELECT *
FROM `post`
WHERE title LIKE '%<b></b>%'

2.删除post表中 title 字段包含<b></b>的数据

DELETE
FROM `post`
WHERE title LIKE '%<b></b>%'

如果有替换包含指定的字符串,使用mysql的replace函数替换字符串:



在数据转换的时候经常需要用到mysql的replace函数批量替换数据,这里简单介绍一下!

1.比如你要将 表 t_article 里面的 attach_1字段的 UploadFiles 替换为 Files

UPDATE t_article SET attach_1=REPLACE(attach_1, 'UploadFiles', 'Files');

2.把content表的 content字段 的 http://www.0058.net/tools/ 内容 替换成 http://www.0058.net/

update `content` set `content`= replace(`content`,'http://www.0058.net/tools/','http://www.0058.net/')

REPLACE(str,from_str,to_str)
在字符串 str 中所有出现的字符串 from_str 均被 to_str替换,然后返回这个字符串:
mysql> SELECT REPLACE('www.0058.net', 'w', 'Ww');
-> 'WwWwWw.0058.net'
这个函数是多字节安全的。
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

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 03:04 AM.


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