If you’re getting an error that reads “The used SELECT statements have a different number of columns” in MySQL, it’s probably because you’re using the EXCEPT
, INTERSECT
, or UNION
clause, but with a different number of columns for each query.
When we use these clauses, both queries must select the same number of columns. For example, if the first query has two columns in its SELECT
list, then the second query must also have two columns in its SELECT
list.
To fix, make sure both queries select the same number of columns.
Continue reading