Fix “ERROR:  each UNION query must have the same number of columns” in PostgreSQL

When using the UNION operator in PostgreSQL, if you encounter an error that reads “ERROR:  each UNION query must have the same number of columns“, it’s because there’s a mismatch in the number of columns returned by the queries on either side of the UNION operator.

This error occurs when the number of columns returned by each SELECT statement is different.

The way to fix this is to ensure that both SELECT statements return the same number of columns.

Read more

Find All Non-Numeric Values in a Column in MariaDB

If you ever encounter a character column that should be a numeric column, there’s always a possibility that it contains non-numeric data that you don’t know about.

In MariaDB, you can run a query like the following to return non-numeric data from the column.

Read more