If you need to return all rows that contain at least one numerical digit in MySQL, the following example might come in handy.
Continue readingCategory: MySQL
2 Ways to List all Functions in MySQL
Below are two options we can use to return a list of functions in MySQL.
Continue readingHow to Check a Column’s Data Type in SQL
In SQL, the columns
information schema view, which returns information about columns, is an ISO standard view that is supported by most of the major RDBMSs. You can use this view to get information about a column’s data type.
Most of the major RDBMs also provide other methods for getting column information.
Here are examples of getting the data type of a column in various SQL databases.
Continue readingSCHEMA() Function in MySQL
In MySQL, the SCHEMA()
function is a synonym for the DATABASE()
function. It returns the default (current) database name.
The result is returned as a string in the utf8
character set. If there is no default database, it returns NULL
.
How to Find Non-Numeric Values in a Column in MySQL
In MySQL, you can run a query like the following to return non-numeric data from the column.
This can be helpful if you ever find a column that contains numeric data, but it was set up as a varchar
or char
column. You can use this query to find any non-numeric values that might have been inserted into the column. You can then deal with it any way you like, such as convert them to numeric, then change the column type.
4 Ways to Check a Column’s Data Type in MySQL
Here are four ways to get the data type of a column in MySQL.
Continue readingHow to Format Numbers with Commas in SQL
Most of the major RDBMSs have functions that enable us to format numbers with commas as either the group separator, or the decimal separator.
Some RDBMSs also output certain numeric data types with commas in the relevant place.
Below are examples of formatting numbers with commas in some of the more popular DBMSs.
Continue readingDATABASE() – Get the Current Database Name in MySQL
In MySQL, DATABASE()
is a built-in function that returns the default (current) database name.
The result is returned as a string in the utf8
character set. If there is no default database, it returns NULL
.
SUM() Function in MySQL
In MySQL, the SUM()
aggregate function returns the sum of a given expression.
It can also be used to return the sum of all distinct (unique) values in an expression.
Continue readingFormat a Number as a Percentage in SQL
There are several ways to format a number as a percentage in SQL, depending on the DBMS being used.
Here are examples of adding a percent sign to a number in some of the most popular DBMSs.
Continue reading