In MariaDB, we can use the LOWER()
function to convert uppercase characters to their lowercase equivalent.
We can alternatively use LCASE()
, which is a synonym of LOWER()
.
In MariaDB, we can use the LOWER()
function to convert uppercase characters to their lowercase equivalent.
We can alternatively use LCASE()
, which is a synonym of LOWER()
.
Below are examples of using SQL to return the first day of the month across various DBMSs.
This could be the first day of the current month, or the first day of a month based on a given date.
Continue readingA generated column is a database column whose value is an expression. Therefore, the value of the generated column is usually derived (for example, it could be derived from values in other columns).
Generated columns are also sometimes referred to as computed columns or virtual columns.
Creating a generated column in MariaDB is essentially the same as creating a normal column. The difference is that the definition of the generated column contains an expression that determines the column’s value.
Continue readingThe following examples use SQL to delete duplicate rows that have a primary key or unique identifier column.
Specifically, the examples delete all duplicates except one. So for example, in the case of three identical rows, it deletes two of them and keeps one.
Continue readingHere are examples of using SQL to return rows that contain non-alphanumeric characters in various DBMSs.
Non-alphanumeric characters include punctuation characters like !@#&()–[{}]:;',?/*
and symbols like `~$^+=<>“
, as well as whitespace characters like the space or tab characters.
Here are three options for returning the first day of a month in MariaDB.
This could be the first day of the current month, or the first day of the month based on a date that we specify.
Continue readingIf you ever need to use SQL to return just the numeric values in a character column, the method you use will largely depend on your DBMS. Most DBMSs support regular expressions (regex), but some don’t. And some include functions that can detect numeric values.
Here are examples of how to do it in the more popular DBMSs.
Continue readingIn MariaDB, the CASE
statement can be used in stored programs to perform a complex conditional construct. It compares a list of conditions and returns a different result depending on which condition (if any) is matched.
The CASE
statement is distinct from the CASE
operator, in that the CASE
statement is specifically for use in stored programs. Also, there’s a slight difference in the syntax.
Most RDBMSs provide at least a few ways to return rows that contain uppercase characters. Here are some options available in the major RDBMSs.
Continue readingIn MariaDB, the NVL2()
function allows us to replace a value with another value, the new value being determined by whether or not the initial value is null.
It’s similar to the NVL()
function, except that NVL2()
accepts three arguments instead of two. This allows us to specify a different value to return in the event the first argument is not null.