Dark Mode
Image

SQL Tutorial

SQL Database

SQL Injection

PL/SQL Tutorial

Sql Interview Question

SQl Quiz

LTRIM Function in SQL

This string function truncates the given character or sub-string from the left of the given original string. It also truncates the space from the left of the specified string.

Syntax of LTRIM String Function

Syntax1: This syntax uses the LTRIM function with the column name of the SQL table:

 SELECT LTRIM(Column_Name, string) AS Alias_Name FROM Table_Name;  

In the syntax, we have to specify the name of that column on which LTRIM function is to be run.

Syntax2: This syntax uses the LTRIM function with the set of characters (string):

        SELECT LTRIM(Original_String, trimmed_string);  

Syntax3: This syntax uses LTRIM function with a single character:

       SELECT LTRIM(Original_String, trimmed_character);  

Examples of LTRIM String function

Example 1: The following SELECT query truncates the given space from the specified string according to the LTRIM function:

    SELECT LTRIM(  '          JAVATPOINT','  ');  

Output:

'JAVATPOINT'

Example 2: The following SELECT query truncates the space from the specified string according to the LTRIM function:

SELECT LTRIM(  '              JAVATPOINT           ');  

Output:

'JAVATPOINT           '

Example 3: The following SELECT query trims the CAPITAL OF INDIA substring from the specified string:

  SELECT LTRIM(  'NEW DELHI IS THE CAPITAL OF INDIA', 'NEW DELHI IS THE ');  

Output:

CAPITAL OF INDIA

Example 4: The following SELECT query trims the given symbol from the specified string:

      SELECT LTRIM(  '####98221545###', '#');  

Output:

98221545###

Example 5: The following SELECT query trims the given set of numbers from the specified string:

  SELECT LTRIM(  '2021JavaTpoint2021', '2021');  

Output:

JavaTpoint2021

Example 6: The following SELECT query trims the given set of numbers from the specified string:

   SELECT LTRIM(  '202120212021JavaTpoint', '2021');  

Output:

JavaTpoint

Example 7: The following SELECT query trims all the numbers from the left side of the string which are present in the trimmed string:

SELECT LTRIM(  '90287JavaTpoint', '0123456789');  

This command actually removes the individual occurrence of numbers of the trimmed string.

Output:

JavaTpoint

Example 8: This example uses the LTRIM function with the table in Structured Query Language.

First, we have to create the new SQL table, which helps to understand the LTRIM string function. The syntax for creating the new table in the SQL database is as follows:

Comment / Reply From