View Single Post
  #3  
Old June 1st, 2010, 10:02 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Union Query and Field Alias

Try this --
SELECT *, "TodBefore10" AS qry_Source FROM [qryTodBefore10]
UNION
SELECT *, "Tod10To12" FROM [qryTod10To12]
UNION
SELECT *, "Tod12To2" FROM [qryTod12To2]
UNION
SELECT *, "TodAfter2" FROM [qryTodAfter2];

--
Build a little, test a little.


"SSi308" wrote:

I have created a union query and now want to create a field alias to specify
which records come from which query.
The union query works as such:
SELECT * FROM [qryTodBefore10]
UNION
SELECT * FROM [qryTod10To12]
UNION
SELECT * FROM [qryTod12To2]
UNION
SELECT * FROM [qryTodAfter2];


But when I try to add the field alias I get the error: Syntax Error in From
clause. The error is not any more specific than that. I have tried so many
different statements I thought it may be better to just ask: What is the
correct syntax to add a field alias called [TimeOfDay]?

Thanks.

Lori