If you think a MySQL table might have duplicate rows, you can use the following options to return all duplicates.
Continue readingCategory: Relational
How to Get Values That Don’t Contain Numbers in MariaDB
When working with MariaDB, you may occasionally find yourself needing to return all rows that don’t contain any numbers.
Technically, numbers can be represented by words and other symbols, but for this article “number” simply means “numerical digit”. So we’re finding values that don’t contain any numerical digits.
Continue reading3 Ways to Return the Modulo in MariaDB
The modulo operation returns the remainder or signed remainder of a division, after one number is divided by another.
If you need to get the modulo of a number in MariaDB, here are three options.
Continue readingHow to Get Multiple Rows into a Comma Separated List in SQL
Most of the major RDBMSs have a function that enables us to return our query results as a comma separated list.
That is, we can use such a function to convert each row into a separate list item, within a comma separated list.
Below are examples of how to achieve this in some of the more popular RDBMSs.
Continue reading3 Ways to Return Rows that Contain Alphanumeric Characters in SQL Server
Here are three examples of returning rows that contain alphanumeric characters in SQL Server.
Alphanumeric characters are alphabetic and numeric characters.
Continue readingDelete Duplicate Rows in SQL Server
The following example uses T-SQL to delete duplicate rows in SQL Server.
To be more specific, it deletes duplicate rows but keeps one. So if you have two identical rows, it deletes one of them and keeps the other. In other words, it de-dupes the table.
Continue readingHow to Return Elements from a JSON Array in MariaDB
MariaDB includes two selectors that enable us to select elements from JSON arrays:
[N]
selects element number N in the array (for example,[0]
to select the first element).[*]
selects all elements in the array.
These can be used in a number of JSON functions that are included in MariaDB. The following examples use them with the JSON_EXTRACT()
function in order to return selected array elements.
3 Ways to Find Rows that Contain Lowercase Letters in MySQL
Here are three options for returning rows that contain lowercase characters in MySQL.
Continue readingFix Error Msg 4151 “The type of the first argument to NULLIF cannot be the NULL constant because the type of the first argument has to be known” in SQL Server
If you get error Msg 4151 “The type of the first argument to NULLIF cannot be the NULL constant because the type of the first argument has to be known” in SQL Server, it’s because you’re passing a null value as the first argument to the NULLIF()
function.
To fix this error, make sure you do not pass the null constant as the first argument to the function. Or if you do, then convert it to a specific data type.
Continue readingHow to Create a Table Only if it Doesn’t Exist in SQLite
In SQLite, you can use the IF NOT EXISTS
clause of the CREATE TABLE
statement to check whether or not a table or view of the same name already exists in the database before creating it.
Creating a table without this clause would normally result in an error if a table of the same name already existed in the database. But when using the IF NOT EXISTS
clause, the statement has no effect if a table already exists with the same name.