-1

列の5番目の文字を最後から変更する必要があります。

例えば、

  • path / of / images / 1232323_ m.jpg

  • path / of / images / 1232323_ b.jpg

MySQLクエリを使用してそれを行う方法は?

4

3 に答える 3

4
update your_table
 set col = concat(substring(col, 1, length(col) -5), 'b', substring(col, -4))
where length(col) > 5  --if you really need.

http://sqlfiddle.com/#!2/31774/2

于 2012-08-29T12:21:59.403 に答える
1

どうですか

update your_table
set col = replace(col, 'm.jpg', 'b.jpg')
于 2012-08-29T12:20:56.567 に答える
1

小切手

select col, if(length(col)<5,col,concat(substr(col,1,length(col)-5),'X',substr(col,length(col)-3,5))) from table;

それに基づいて更新を実行します。

update table set col=concat(substr(col,1,length(col)-5),'X',substr(col,length(col)-3,5)) where length(col)>5;

実際の例: http://sqlfiddle.com/#!2/dbc21/2/0

于 2012-08-29T12:22:45.657 に答える