网站再改造一下|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)
【版權聲明】
本文爲原創,遵循CC 4.0 BY-SA版權協議!轉載時請附上原文鏈接及本聲明。
原文鏈接:https://tdlib.com/am.php?t=PD33pYy3cKr8 Tag: Pic