MariaDB MySQL Functions

Common MariaDB MySQL Functions

Common MariaDB MySQL Functions used in the WPDB Power Tool as well as ones used in general with applications that have a MariaDB/MySQL database backend.

CONCAT: Combines text in a string or in other words adds strings together.
Usage: SELECT CONCAT(‘The time is ‘, NOW());
DATE_FORMAT: Formats date and time in anyway you can specify. There are 36 date time options at present and a current list is fully displayed at mariadb.com here. Commonly used options:

%a Day as: Sun Mon Tues%b Month as: Oct Nov Dec%c Month as: 9 10 11%D Day as : 1st 2nd 3rd 4th
%d Day as: 08 09 10%e Day as: 8 9 10%S or %s seconds as: 00-59%H Hour as: 0023
%h or %I Hour as: 0112 %p for AM or PM%i Minute as: 0059%k Hour as: 023%l Hour as: 112
%M Month as: January%m Month as: 0112%W Weekday as: Monday%U Week # as: 0053
%w day of week as: 06%Y Year as: 2021%y Year as: 21%V Week # as: 0153
There are more. However these are commonly used.

Usage Examples:
SELECT DATE_FORMAT(NOW(), '%W %M %Y'); # Output like: Wednesday March 2021
SELECT DATE_FORMAT(NOW(), '%m/%d/%Y'); # Output like: 03/25/2021
SELECT DATE_FORMAT(NOW(), '%a %M %D, %Y'); # Output like: Thu March 25th, 2021
SELECT DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s'); # Output like: 2021-03-25 15:53:14
DATE_FORMAT(NOW(), '%W %b %D, %Y at %l:%i:%s %p'); #Output like:Wednesday Mar 31st, 2021 at 4:29:20 PM
You can replace NOW() with a DATETIME field for the same format results.

FROM_UNIXTIME: Displays UNIX/LINUX Epoch timestamp as readable format. Usage:
Usage: SELECT CONCAT('EPOCH TIME 2147483647 ', FROM_UNIXTIME(2147483647), ' High as MariaDB goes not one second more! ');
LOWER() or LCASE(): Converts all alpha charcters to lower case.
Usage: SELECT LOWER('NOT UPER CASE ANYMORE!');
NOW(): Gets the time to the second of NOW.
Usage: SELECT NOW();
UPPER() or UCASE(): Converts all lower case characters to upper case.
Usage: SELECT UPPER('no longer lower case!');

Complete list can be obtained at MariaDB.