When using the UNION
operator in MariaDB, you may encounter the following error: “ERROR 1222 (21000): The used SELECT statements have a different number of columns”.
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.