From 518345fdc86e2cb4394412720e277e6e7ef47896 Mon Sep 17 00:00:00 2001 From: D023426 Date: Wed, 27 May 2026 16:04:31 +0200 Subject: [PATCH] Substring: more doc, more examples --- Substring.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Substring.md b/Substring.md index b9e62f7..14867f8 100644 --- a/Substring.md +++ b/Substring.md @@ -1,7 +1,31 @@ # Keyword `SUBSTRING` AlaSQL supports ```SUBSTRING(string, start, length)``` function: + +```string```: The string you want to slice. + +```start```: Where the substring should start. Positive value counts from left. First character is ```1```. Zero and negative values count from right where ```0``` is the last character. + +```length```: How many characters shall the substring have. If ```length``` is left out or larger than the rest of the ```string```, then ```SUBSTRING``` returns all remaining characters. + +## Examples + ```sql - SELECT SUBSTRING('abc',1) + SELECT SUBSTRING('abcd',1) + -- returns 'abcd' + SELECT SUBSTRING('abcd',3) + -- returns 'cd' + SELECT SUBSTRING('abcd',1,2) + -- returns 'ab' + SELECT SUBSTRING('abcd',2,2) -- returns 'bc' + SELECT SUBSTRING('abcd',2,4) + -- returns 'bcd' + SELECT SUBSTRING('abcd',0) + -- returns 'd' + SELECT SUBSTRING('abcd',-1) + -- returns 'cd' + SELECT SUBSTRING('abcd',-5,3) + -- returns 'abc' ``` +