From 93a663cc9c91e2aa91765dddc788110012540e55 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 20 Nov 2024 09:32:45 -0600 Subject: [PATCH] Adjust formatting, add source link to pg TIL --- postgres/between-symmetric.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/postgres/between-symmetric.md b/postgres/between-symmetric.md index 1292d97..34f926d 100644 --- a/postgres/between-symmetric.md +++ b/postgres/between-symmetric.md @@ -4,7 +4,9 @@ PostgreSQL's `between` construct allows you to make a comparison _between_ two values (numbers, timestamps, etc.). ```sql -> select * from generate_series(1,10) as numbers(a) where numbers.a between 3 and 6; +> select * + from generate_series(1,10) as numbers(a) + where numbers.a between 3 and 6; a --- 3 @@ -17,7 +19,9 @@ If you supply an empty range by using the larger of the two values first, an empty set will result. ```sql -> select * from generate_series(1,10) as numbers(a) where numbers.a between 6 and 3; +> select * + from generate_series(1,10) as numbers(a) + where numbers.a between 6 and 3; a --- ``` @@ -26,7 +30,9 @@ Tacking `symmetric` onto the `between` construct is one way to avoid this issue. ```sql -> select * from generate_series(1,10) as numbers(a) where numbers.a between symmetric 6 and 3; +> select * + from generate_series(1,10) as numbers(a) + where numbers.a between symmetric 6 and 3; a --- 3 @@ -39,3 +45,5 @@ issue. > that the argument to the left of AND be less than or equal to the argument > on the right. If it is not, those two arguments are automatically swapped, > so that a nonempty range is always implied. + +[source](https://www.postgresql.org/docs/current/functions-comparison.html#:~:text=BETWEEN%20SYMMETRIC%20is%20like%20BETWEEN,nonempty%20range%20is%20always%20implied.)