Allen 2020-05-16 10:57:40 121823 0 0 0 0

网站再改造一下|Pic

目标

summary原来保存的文件路径和文件名,将其移到新字段pic_file中

summary保存从标题中提取Tag字符串,作为Tag用。

.

--增加新字段:pic_file,保存图片文件路径和文件名

ALTER TABLE hy_thread ADD COLUMN pic_file VARCHAR(50) DEFAULT NULL;

update hy_thread set pic_file=concat("/",summary) where tid>9;

--查找标题中|位置

select instr(title,"|"),length(title) from hy_thread;

--截取标题中|后的字符

select substring(title,instr(title,"|")+1,length(title)-instr(title,"|")) from hy_thread

--替换截取的字符串,把空格换成逗号

select replace(substring(title,instr(title,"|")+1,length(title)-instr(title,"|"))," ",",") from hy_thread

--把截取到的字符串作为tag更新到字段summary

update hy_thread set summary=replace(substring(title,instr(title,"|")+1,length(title)-instr(title,"|"))," ",",")

where length(title)>0

(更新490

--更新标题为空的记录,赋默认标题,清空summary

select * where length(title)=0

update hy_thread set title="Beautiful Photo",summary="" where length(title)=0

(4298)


Tag: Pic
相关内容
欢迎评论
未登录,
请先 [ 注册 ] or [ 登录 ]
(一分钟即可完成注册!)
返回首页     ·   返回[站点日志]   ·   返回顶部