Here are two ways to concatenate strings and numbers in MariaDB:
- Use the
CONCAT()function, which concatenates its arguments. - Use the pipe concatenation operator (
||), which concatenates its operands.
Below are examples of each.
Here are two ways to concatenate strings and numbers in MariaDB:
CONCAT() function, which concatenates its arguments.||), which concatenates its operands.Below are examples of each.
SQLite has a printf() function or format() function that allows us to format numbers according to a format string.
As from SQLite 3.18.0, it accepts a comma flag, which enables us to have comma separators at the thousands marks for integers.
Further work can be done to get it working with real/floating point numbers.
Here’s a list of units that can be used in MySQL datetime and interval functions.
In PostgreSQL, the CONCAT_WS() function concatenates two or more strings, placing a separator between each one. The separator is specified by the first argument.
There are a couple of approaches we can use to concatenate strings and numbers in MySQL.
CONCAT() function, which concatenates its arguments.||), which concatenates its operands.Below are examples of each.
Oracle Database has the TO_CHAR(datetime) function that enables us to get various date parts from a datetime value.
There’s also the EXTRACT(datetime) function that extracts a specific datetime unit (e.g. day, month, year, etc).
When using SQLcl to run queries against Oracle Database, you can specify the output of the query results using the following two options:
SET SQLFORMAT commandIn PostgreSQL, the CONCAT() function concatenates the text representations of its arguments.
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.