Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql Sql-functions Mysql Ltrim

Related Tutorials


 
 

Share on Google+Share on Google+

Mysql Ltrim

Advertisement
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)

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 16, 2009

Related Tutorials

Discuss: Mysql Ltrim  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com