Mysql Ltrim

Mysql Ltrim is used to remove the left leading and trailing spaces in the
string.
Understand with Example
The Tutorial illustrate an example from 'Mysql Ltrim'.To understand this
example,we create a procedure 'ABC' that include a BEGIN-END statement
consists of declare variables. The concat keyword in the given query is
used to concatenated the string.The select name return you the trailing
spaces in the concatenated string.Now ,inorder to remove the left leading and
trailing spaces in the string we use ltrim keyword that removes the
trailing spaces in the two name between Girish and Tewari.
Query to create procedure to use Ltrim Function:
mysql> delimiter $$
mysql> CREATE PROCEDURE ABC()
-> Begin
-> Declare fname varchar (10) default 'Girish';
-> Declare lname varchar (10) default 'Tewari';
->
-> Declare name varchar(30);
->
-> set lname = concat(' ', lname);
-> set name = concat(fname , lname);
-> select name;
->
-> set name = concat(fname , ltrim(lname));
-> select name;
-> end$$
Query OK, 0 rows affected (0.00 sec)
|
Output:
The call abc( ) keyword is used to execute the procedure abc ( ).
mysql> delimiter ;
mysql> call abc();
+---------------+
| name |
+---------------+
| Girish Tewari |
+---------------+
1 row in set (0.00 sec)
+--------------+
| name |
+--------------+
| GirishTewari |
+--------------+
1 row in set (0.09 sec)
Query OK, 0 rows affected (0.20 sec)
|

|