アンディ:
私のテーブルには、エントリ(画像のパス)がたくさんあります。このような文字列は、そのようなURLとルックスです
https://example.com/images/do.php?id=1234
そして、私はすべてこの形式に変更する必要があります
https://example.com/images/1234.png
だから、「ID」は、ファイル名と同じです。ちょうどURLを交換することは難しいが、私は私の場合には、URL文字列の末尾に「PNG」である静的なファイルの拡張子を、追加することが必要であることではありません。私はそのような何かを必要とするので、
UPDATE post SET message = REPLACE(message, 'https://example.com/images/do.php?id=', 'https://example.com/images/{id}.png');
私は全く経験豊かなSQLユーザーですので、あなたが助け私を喜ばせることができますか?
ゴードン・リノフ:
これは、あなたの質問に例えば動作します。
select concat(substring_index(path, 'do.php', 1),
substring_index(path, '=', -1),
'.png')
from (select 'https://example.com/images/do.php?id=1234' as path) x
あなたは簡単にこれを回すことができますupdate
。
update post
set message = concat(substring_index(message, 'do.php', 1),
substring_index(message, '=', -1),
'.png')
where message like '%do.php%=%';