When using PostgreSQL’s INTERSECT
operator, if you encounter an error that reads “ERROR: each INTERSECT 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 INTERSECT
operator.
The way to fix this is to ensure that both SELECT
statements return the same number of columns.