Rex
asked on
I want to make a Union Query in Access 2010, but not use all the Fields in both Tables
I have always used the structure that combines two tables in their entirety, but now I need to union parts of two tables that are not alike, but do contain some of the same fields.
Can someone please give me the syntax for doing that? A Union of two tables with some fields, not all?
Thanks
Rex
Can someone please give me the syntax for doing that? A Union of two tables with some fields, not all?
Thanks
Rex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Union requires that the number of columns and their datatypes be the same in both select statements so, if a given column does not exist in one of the selects, you must substitute a literal value or null as has been indicated. In that instance the use of union all will perform better since no duplicates can exist. If there are no missing columns, but you only wish to select certain ones, just list the column names that meet the criteria for the number of columns and datatypes.
ASKER
Sorry! Forgot to close it.
thanks
Rex
thanks
Rex
glad to help
Select Field1, Field2, 0 As Field3, "N/A" As Field4, Null As Field5 From tblWithMissingFields
/gustav