In SQL Server, you can use the LEFT()
function to extract the left part of a string.
It works exactly the same as the RIGHT()
function (which returns the right part of a string), except that it returns the left part of the string.
In SQL Server, you can use the LEFT()
function to extract the left part of a string.
It works exactly the same as the RIGHT()
function (which returns the right part of a string), except that it returns the left part of the string.
I thought it would be interesting to run a few quick queries to see how various formatting strings affect the formatting of date/time values.
In Postgres, to_char()
is a data type formatting function that converts its first argument to a string.
The format of the string is determined by the second argument.
The to_char()
function can be used to do the following conversions:
In SQLite, you can use the instr()
function to return the position of a given character within a string.
The function only returns the position of the first occurrence of the character (if any).
If the character isn’t found, then it returns 0.
If either of the arguments are NULL, then it returns NULL.
Continue readingThe SQLite length()
function returns the number of characters in a string, number, or blob.
If there are any NUL characters, it returns the number of characters before the first NUL character.
Continue readingThe SQLite quote()
function allows you to escape a string so that it’s suitable for inclusion in an SQL statement.
Strings are surrounded by single-quotes with escapes on interior quotes.
BLOBs are encoded as hexadecimal literals.
Note that strings with embedded NUL characters cannot be represented as string literals in SQL. If you include strings with embedded NUL characters, the returned string literal is truncated prior to the first NUL.
Continue readingThe SQLite replace()
function enables us to replace one string (or part of a string) with another string.
The way it works is that you provide three arguments; the string that contains the substring to replace, the substring within that string to replace, and the string to replace it with.
Continue readingIn SQLite, you can use the unicode()
function to return the unicode code point for a given character.
The way it works is that it returns the unicode code point for the first character of the string that you provide.
Continue readingSQLite has a group_concat()
function that allows you to concatenate multiple results returned for a column into one.
This is sometimes referred to as “string aggregation”.
For example, when querying a database, instead of having each column’s value output in a new row, you can use group_concat()
to have them output as a comma separated list.
The SQLite substr()
function allows you to return a substring from a string, based on a given starting location within the string.
It requires two arguments, and accepts a third optional argument.
Continue reading