Union Query

Union Query

I am writing a SQL statement in Access that is a union query. I am getting an error saying “The number of columns in the two selected tables or queries of a union query do not match.” I put NULL’s in there to see if it would work, but it doesn’t.

I understand I need to have the same amount of fields, but what can I do if I want only select fields in certain SELECT statements?

You can use null values for columns that you don’t select. However, the column must have the same name. Here’s a simple union query where the first table has three columns and the second table has two columns. The third column is just set to NULL in the query:

SELECT name, age, cityFROM TableAUNIONSELECT name, age, city=nullFROM TableB


Share the Post: