From 1fd64e478a8cd06274e622f867fad311fffdaf32 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 31 Jan 2025 14:34:53 -0600 Subject: [PATCH] Clarify some things in the latest TIL --- ...-leading-and-trailing-space-from-string.md | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/postgres/trim-leading-and-trailing-space-from-string.md b/postgres/trim-leading-and-trailing-space-from-string.md index 2cf6ef2..8bd6494 100644 --- a/postgres/trim-leading-and-trailing-space-from-string.md +++ b/postgres/trim-leading-and-trailing-space-from-string.md @@ -5,10 +5,20 @@ functions](https://www.postgresql.org/docs/current/functions-string.html), including several for doing various string trimming. We can use the simplest form of `trim` to remove leading and trailing space -characters from a string. The syntax for calling `trim` is a bit odd relative -to other PostgreSQL functions and functions in other languages. +characters from a string. -Here is the "grammar" as described in the docs: +```sql +> select trim(' Taco Cat '); ++----------+ +| btrim | +|----------| +| Taco Cat | ++----------+ +``` + +The syntax for calling `trim` is a bit odd relative to other PostgreSQL +functions and functions in other languages. Here is the "grammar" as described +in the docs: ``` trim ( [ LEADING | TRAILING | BOTH ] [ characters text ] FROM string text ) → text @@ -42,3 +52,7 @@ string: | aco Ca | +--------+ ``` + +Notice that in all the above examples the column name of the result is `btrim`. +That's probably because `btrim` (_trim both ends_) is being called under the +hood for the `both` option.