cant remove whitespace even using trim sql

2828 views mysql

hai guys please help me i can't remove the whitespace eventhough im using trim()

can anybody help me


example data :' testing123'

answered question

1 Answer


Try using replace function

select replace(col1,' ','') as col1,
length(col1) as withSpace,length(replace(col1,' ',''))as withoutspace from t

Check demo of answer here demo solution

You can see that column withSpace shows length of text without any replacement and column withoutspace shows length of text after replacement.

posted this

Have an answer?


Please login first before posting an answer.