While dealing with string data type in MySQL, its observed that sometimes unnecessary space character comes in between which hampers the successful execution of a string manipulation module. Name the suitable MySQL function (s) to remove leading, trailing and both type of space characters from a string. Also give MySQL queries to depict the same.

4 views

1 Answers

i. To remove leading space characters: ltrim() 

ii. To remove trailing space characters: rtrim() 

iii. To remove both type of space characters: trim() 

MySQL Queries: 

Select ltrim(‘ Hello ’); 

Select rtrim(‘ Hello ’); 

Select trim(‘ Hello ’); 

Output:

Hello 

4 views