7 Options for Enabling Pipes (||) as the Concatenation Operator in MariaDB

By default, two pipe characters (||) are treated as a logical OR operator in MariaDB. However, you can change this behaviour if you like.

You can update your sql_mode to include the PIPES_AS_CONCAT option, in which case two pipes will be treated as a concatenation operator.

There are quite a few ways to add this option to your sql_mode. You can add it explicitly. Or you can set your sql_mode to an option that sets it implicitly.

I run through these options below.

Continue reading

How to Format Numbers as Currency in MySQL

Some DBMSs provide us with the ability to format a number as a currency by providing a format specifier for the currency symbol. Providing such a format specifier allows the DBMS to return the appropriate currency symbol for the locale.

MySQL doesn’t have a currency format specifier, and so we need to do a bit of extra work if we want the currency symbol to be returned.

Continue reading