SQLite-替换字符串的一部分
在SQLite中是否可以替换字符串的一部分 比如说SQLite-替换字符串的一部分,sqlite,replace,Sqlite,Replace,在SQLite中是否可以替换字符串的一部分 比如说 updatepages SET path=replace(路径“/page”、“/article”),其中路径类似“/page/%”“ 结果 /page/page1/page2=>/article/article1/article2 但我需要 /page/page1/page2=>/article/page1/page2就像这样做: UPDATE pages SET path = replace(path, '/page/', '/articl
updatepages SET path=replace(路径“/page”、“/article”),其中路径类似“/page/%”“
结果
/page/page1/page2=>/article/article1/article2
但我需要
/page/page1/page2=>/article/page1/page2
就像这样做:
UPDATE pages SET path = replace(path, '/page/', '/article/') WHERE path LIKE '/page/%'"
及
确实对我有帮助但如果路径等于/page/page/page,则这将没有帮助。并且存在此路径的可能性
$l1 = strlen($old_path);
$l2 = $l1+1;
UPDATE pages
SET path = replace(
substr(path, 1, {$l1}),
'{$old_path}',
'{$new_path}'
) || substr(path,{$l2})
WHERE path LIKE '{$old_path}/%'