SQL Trim | Trim Command in SQL - sql - sql tutorial - learn sql




 trim command in sql
  • The TRIM function in SQL is used to remove a specified prefix or suffix from a string.
  • The most common pattern being removed is the white space.
  • TRIM is a function that takes a character expression and returns that expression with leading and/or trailing pad characters removed.
  • Optional parameters indicate whether leading, or trailing, or both leading and trailing pad characters should be removed, and specify the pad character that is to be removed.

This function is called differently in different databases:

  • MySQL: TRIM( ), RTRIM( ), LTRIM( )
  • Oracle: RTRIM( ), LTRIM( )
sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

Syntax

Tags : sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

The syntax for the TRIM function is as follows:

TRIM( [ [LOCATION] [remstr] FROM ] str)
  • [LOCATION] can be either LEADING, TRAILING, or BOTH.
  • This function gets rid of the [remstr] pattern from either the beginning of the string or the end of the string, or both.
  • If no [remstr] is specified, white spaces are removed.

The syntax for the LTRIM function is as follows:

LTRIM (str)
  • LTRIM removes all white spaces from the beginning of the string.

The syntax for the RTRIM function is as follows:

RTRIM (str)

  • RTRIM removes all white spaces at the end of the string.

Examples

sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

Example 1: TRIM function

SELECT TRIM('   Wikitechy   ');

Result:

'Wikitechy'
sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

Example 2: LTRIM function

SELECT LTRIM('   Wikitechy   ');

Result:

'Wikitechy   '
sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

Example 3: RTRIM function

SELECT RTRIM('   Wikitechy   ');

Result:

'   Wikitechy'

This tutorial provides more the basic needs and informations on sql tutorial , pl sql tutorial , mysql tutorial , sql server , sqlcode , sql queries , sql , sql formatter , sql join , w3schools sql , oracle tutorial , mysql , pl sql , learn sql , sql tutorial for beginners , sql server tutorial , sql query tutorial , oracle sql tutorial , t sql tutorial , ms sql tutorial , database tutorial , sql tutorial point , oracle pl sql tutorial , oracle database tutorial , oracle tutorial for beginners , ms sql server tutorial , sql tutorial pdf

Related Searches to SQL Trim | Trim Command in SQL