Home Sql Sql-functions Mysql Ltrim



Mysql Ltrim
Posted on: January 16, 2009 at 12:00 AM
Mysql Ltrim is used to remove the left leading and trailing spaces in the string.

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)

 

Related Tags for Mysql Ltrim:
sqlmysqlcstringsedremoveaimovespacestrimtoeilspaceliuseimceleftinmtradaceesemssppacmyisleadingeaandstrtrailssriringthstleadmovndo


More Tutorials from this section

Ask Questions?    Discuss: Mysql Ltrim  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.