The number of columns in the two selected tables or queries of a union query do not match. (Error 3307)
The two tables or queries joined by the UNION operation must generate the same number of columns. Remove columns from the SELECT statement that has too many columns or include more columns in the SELECT statement that has too few.
You can include constants instead of columns in the SELECT statement that has too few columns. For example, the following union query generates three columns from the first SELECT statement but one column and two constants in the second SELECT statement. The query returns all countries in the Employees and Regions tables. From the Employees table, the query also returns the first and last name of an employee. If the country value is from the Regions table, however, the query returns Null in the First Name and Last Name columns.
SELECT Country, FirstName, LastName FROM Employees
UNION SELECT Country, NULL, NULL FROM Regions;
Was this page helpful?
Your feedback about this content is important. Let us know what you think.
1500 characters remaining
We appreciate your feedback.
Have a suggestion to improve MSDN Library?
Visit our UserVoice Page to submit and vote on ideas!