代码原因导致文件路径异常,如需将filePath字段内容的第一个“.”和第二个“.”之间的数据给替换成空
- 获取到需要替换的内容
SELECT id,filePath,
SUBSTRING(filePath,LOCATE('.',filePath),CHAR_LENGTH(filePath)-LOCATE('.',REVERSE(filePath))-LOCATE('.',filePath)+1)
FROM lg_event_materials WHERE length(filePath)!=char_length(filePath) LIMIT 100;
- 替换sql
UPDATE lg_event_materials SET filePath = REPLACE(filePath, SUBSTRING(filePath,LOCATE('.',filePath),CHAR_LENGTH(filePath)-LOCATE('.',REVERSE(filePath))-LOCATE('.',filePath)+1),'')
WHERE length(filePath)!=char_length(filePath);
成功