5

I have a requirement where at first I need to remove all space from a string, then put a space after 3 characters started from right.

I have removed the spaces but putting space after certain characters is not happening.

IE:

AX1098 
AX1 098  
4

2 に答える 2

6
SELECT INSERT('AX1098', 4, 0, ' ');

http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_insert

すべての行を更新するには:

UPDATE YOURTABLE
SET YOURCOL = INSERT(YOURCOL, 4, 0, ' ');
于 2013-01-05T05:50:29.617 に答える
0

文字列の長さが異なる場合:

update t set F = INSERT(F,LENGTH(F)-2,0,' ');
于 2013-01-05T05:57:29.090 に答える