In MariaDB, COLLATION()
is a secondary built in function that returns the collation of a given string.
We provide the string when we call the function.
Continue readingIn MariaDB, COLLATION()
is a secondary built in function that returns the collation of a given string.
We provide the string when we call the function.
Continue readingIn MariaDB, CHAR()
is a built-in string function that returns characters based on their code values.
CHAR()
accepts one or more integers. It then returns a string consisting of the characters given by the code values of those integers.
In MariaDB, CHR()
is a built-in string function that returns a character based on the code values provided as an argument.
In MariaDB, ORD()
is a built-in string function that returns the numeric character code of the leftmost character of its string argument.
The ORD()
function can handle multi-byte characters. This is in contrast to the ASCII()
function, which only handles single-byte (8 bit) characters.
In MariaDB, ASCII()
is a built-in string function that returns the numeric ASCII value of the leftmost character of its string argument.
The ASCII()
function only works on 8 bit characters. To get the code for multi-byte characters, use the ORD()
function instead.
Below is a full list of date/time functions available in PostgreSQL.
Continue readingBelow is a full list of mathematical functions available in PostgreSQL.
These are arranged into the following four categories:
Students learning a new programming language will often start their first lesson with an IF
statement, where their statement will return a value only if the expression is true.
They might then progress to an IF... ELSE
statement, where they can determine another value to return if the expression is false. So therefore, return one value if the expression is true, and another value if it’s false.
SQL Server certainly includes the IF... ELSE
statement in its T-SQL toolbox.
SQL Server also includes the IIF()
function, which does a similar thing, but with a more concise syntax.
But there are some subtle differences.
Continue readingIn SQL Server, the IIF()
function (not to be confused with the IF
statement) is a conditional function that returns the second or third argument based on the evaluation of the first argument.
It’s a shorthand way for writing a CASE
expression. It’s logically equivalent to CASE WHEN X THEN Y ELSE Z END
assuming IIF(X, Y, Z)
.
IIF()
is an abbreviation for Immediate IF.
Postgres has the age()
function that returns the age in years, months, and days based on two dates.
This works fine unless you only want to return the age in years.
For example, you simply want to return a person’s age based on their birthday. You want something like 32 instead of 32 years 4 mons 67 days, which is what age()
is likely to return.
Fortunately there’s an easy way to do this in PostgreSQL.
Continue reading