O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Trimming Characters with TRIM()

Use the TRIM() function to remove unwanted characters from the ends of a string. The TRIM() function’s important characteristics are:

  • You can trim leading characters, trailing characters, or both. (You can’t use TRIM() to remove characters from within a string.)

  • By default, TRIM() trims spaces, but you can strip off any unwanted characters, such as leading and trailing zeros or asterisks.

  • TRIM() typically is used to format results and make comparisons in a WHERE clause.

  • TRIM() is useful for trimming trailing spaces from CHAR values. Recall from “Character String Types” in Chapter 3 that DBMSes automatically add spaces to the end of CHAR values to create strings of exactly a specified length.

  • Trimming has no effect ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required