How to Use the Trim Function

Tutorials Shared by the Internet Community

Advertisements


Synopsis

Sometimes with outputted data, comes unwanted white space. The trim function is used for this in SQL.

Statistics

  • Total Hits - 16543

  • Total Votes - 102 votes

  • Vote Up - 44 votes

  • Vote Down - 58 votes

  • Domain - www.sqltutorials.net

  • Category - Basic SQL/Basic SQL Misc

  • Submitted By - Shekhar

  • Submitted on - 2008-04-11 10:16:17

Description

When running more complex queries, such as concatenating strings, often times you may need to trim whitespace from the values.

Let’s look at an example of this. Remember the query we ran for concatenating:

SELECT CONCAT (productName, ” , ” , price) FROM products;

As it is the output would be XBOX , $399 ...


Site  |   Broken  |   Tweet  |   Facebook  |     |   Save  |   Liked  |   Down

Advertisements