How SQL RTrim () and LTrim () functions are used

Source: Internet
Author: User
Tags rtrim trim

The TRIM function in SQL is used to remove the header or the end of a string of characters. The most common use is to remove the blank at the beginning or end of the word. This function has different names in different repositories:

Mysql:trim (), RTRIM (), LTRIM ()

Oracle:rtrim (), LTRIM ()


SELECT FIRSTNAME | | ' ' || RTRIM (LASTNAME) as "with RTRIM" from STUDENTS WHERE rownum < 11


SELECT
LTRIM (FIRSTNAME) as "LTRIM"
From STUDENTS

SQL Server:rtrim (), LTRIM ()

The syntax for the various trim functions is as follows:

TRIM ([[Location] [string to remove] from]: the possible values for [position] are leading (start), trailing (end), or BOTH (beginning and end). This function removes the string to be removed from the beginning, end, or start and end of the string. If we do not list [the string to be removed], the whitespace will be removed.

LTRIM (String): Removes the blank space from the beginning of all strings.

RTRIM (String): Removes the whitespace from the end of all strings.


WHERE RowNum < 11

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.