How to Use sqlrtrim () and ltrim () Functions

Source: Internet
Author: User
The TRIM function in SQL is used to remove the character header or end of a string. The most common purpose is to remove the leading or trailing blank spaces. This function has different names in different databases: MySQL: TRIM (), RTRIM (), LTRIM () Oracle: RTRIM (), LTRIM () SELECTFIRSTNAME | RTRIM (LASTNAME) AS & quot; TRIM function in WithRTRI SQL is used to remove the character header or tail of a string. The most common purpose is to remove the leading or trailing blank spaces. This function has different names in different databases:

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

Syntax of various trim functions:

TRIM ([[location] [string to be removed] FROM] string): the possible value of [location] is LEADING (start), TRAILING (end ), or BOTH (start and end ). This function removes the [string to be removed] from the start, end, or end of the string. If we do not list what the [string to be removed] is, the blank space will be removed.

LTRIM (string): removes white spaces from the start of all strings.

RTRIM (string): removes the white space at 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.