well, the "UNION Operation" topic in Access Help is confusing (at least in
A2003). from your post, sounds like you're working with two queries, that
you want to combine into one dataset. here's a copy of the example in the
"Examples of union querys (MDB)" topic, which does just that:
SELECT [CompanyName], [City]
FROM [Suppliers]
UNION SELECT [CompanyName], [City]
FROM [Customers]
ORDER BY [City];
this is basically a union of two Select queries. you might find it easier to
substitute your own table and field names by looking at the following:
SELECT [FieldName], [AnotherFieldName]
FROM [QueryName]
UNION SELECT [FieldName], [AnotherFieldName]
FROM [AnotherQueryName]
ORDER BY [SomeFieldName];
you don't need to include the ORDER BY clause unless you want to sort the
records in the dataset. also, you can include the ALL keyword if you don't
mind having any duplicate records included in the dataset. (as the Help
says, the query will run faster that way, because the system doesn't have to
compare records in a search for duplicates to exclude.) the syntax would be
SELECT [FieldName], [AnotherFieldName]
FROM [QueryName]
UNION ALL SELECT [FieldName], [AnotherFieldName]
FROM [AnotherQueryName]
ORDER BY [SomeFieldName];
the important thing to see in the example is that each SELECT statement
includes the same *number* of fields - in this case, 2 fields. that equal
balance is required in a Union query.
if the above doesn't quite get you there, post back with the SQL statements
from your two queries, and we'll see if we can help you figure it out.
hth
"Taylor" <(E-Mail Removed)> wrote in message
news:457F3266-78E6-4B42-96B2-(E-Mail Removed)...
> Hey,
> Okay first of all, I am very new to Acces, SQL, etc. and I did check the
> UNION help but I couldnt figure it out.
> I have 2 queries that have the data I need but I need that data combined
> into 1 table or query so I can export the combined data into a .csv file.
> Here is what I have been playing with:
>
> Select[CombinedDataTable] Query1 UNION [ALL] [TABLE] Query2 [UNION [ALL]
> [TABLE] queryn [ ... ]];
>
> I believe that the [ALL] and [TABLE] things need to say something else. I
am
> not sure I need the "CombinedDataTable". If I do need to create that
table,
> would it have the fields of the queries?
>
> My only workaround is runing my queries individually and saving them to
two
> seperate .csv files then using copy and paste to combine the date. That
takes
> too long. Any help?
>
> Thanks
|