惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
SecWiki News
SecWiki News
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
F
Fortinet All Blogs
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
O
OpenAI News
T
Troy Hunt's Blog
TaoSecurity Blog
TaoSecurity Blog
小众软件
小众软件
MongoDB | Blog
MongoDB | Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
美团技术团队
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
V
Vulnerabilities – Threatpost
B
Blog RSS Feed
NISL@THU
NISL@THU
Security Latest
Security Latest
The Register - Security
The Register - Security
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
N
News and Events Feed by Topic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
罗磊的独立博客
Know Your Adversary
Know Your Adversary
Hacker News: Ask HN
Hacker News: Ask HN
S
Security Affairs
月光博客
月光博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 林宁

apache2 SSI 再论mysql_unbuffered_query与mysql_query的区别 Linux下的软链接和硬链接的不同(转载) TortoiseSVN 简明使用 php自带SOAP扩展调用web service 在linux下定时执行PHP脚本(定时执行crontab使用方法详解) php中构造函数和析构函数执行过程 如何从一个php文件向另一个地址post数据,不用表单和隐藏的变量(转) 字符截取 Linux若干小结备查寻 用 PHP 读取和编写 XML DOM 基本数据结构和php内置函数(转摘) 表单提交按钮图片形式的几种写法 php防注入 随机数、随机数种子 10 件(也许)你不了解 PHP 的事情 手机中的IMEI是什么意思? 一个很不错的验证类,扩展型很好(转载) 百度(baidu)的职业道德
mysql替换数据库中的部分内容
林宁 · 2007-12-14 · via 博客园 - 林宁

例子:将cdb_pms表subject字段中的Welcom to替换成 欢迎光临
UPDATE `cdb_pms`
SET `subject` = REPLACE(`subject`, 'Welcome to', '欢迎光临')
WHERE INSTR(`subject`,'Welcome to') < 0

替换cdb_posts表的message字段,将“viewthread.php?tid=3989”替换成“viewthread.php?tid=16546”

UPDATE `cdb_posts`
SET `message`= REPLACE(`message`, 'viewthread.php?tid=3989', 'viewthread.php?tid=16546')
WHERE INSTR(`message`,'viewthread.php?tid=3989') < 0 ;

删除所有的空格
UPDATE `es_product` SET `pro_pub_time` = TRIM(`pro_pub_time`)

删除所有饱含'['或者']'或者'.'的字符
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '[','') WHERE INSTR(`pro_pub_time`,'[') < 0
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, ']','') WHERE INSTR(`pro_pub_time`,']') < 0
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '.','-') WHERE INSTR(`pro_pub_time`,'.') < 0

替换所有含中文'-'的为英文'-'
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '-','-') WHERE INSTR(`pro_pub_time`,'-') < 0

将所有的年月都替换成'-'
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '年','-') WHERE INSTR(`pro_pub_time`,'年') < 0
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '月','-') WHERE INSTR(`pro_pub_time`,'月') < 0

将所有'2005-04-'这种类型的替换成'2005-04-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT( `pro_pub_time`, '01') WHERE SUBSTRING_INDEX( `pro_pub_time`, '-', -1) = '' AND LENGTH(`pro_pub_time`) < 0 AND LENGTH(`pro_pub_time`) < 5

将所有'2005-'这种类型替换成'2005-01-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT( `pro_pub_time`, '01-01') WHERE INSTR(`pro_pub_time`,'-') < 0 AND LENGTH(`pro_pub_time`) = 5

将所有 饱含'-',但是位数小于8的改成追加'-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT( `pro_pub_time`, '-01') WHERE INSTR(`pro_pub_time`,'-') < 0 AND LENGTH(`pro_pub_time`) > 8

将所有'2005'这样的改成'2005-01-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT(`pro_pub_time`,'-01-01') WHERE INSTR(`pro_pub_time`,'-') = 0 AND LENGTH(`pro_pub_time`) = 4

最后将所有'2005-01-01'格式化成'2005年01月'
UPDATE `es_product` SET `pro_pub_time` = DATE_FORMAT(`pro_pub_time`,'%Y年%m月') WHERE INSTR(`pro_pub_time`,'-') < 0