Can't see what is wrong with this Union query...

A

AndyK

Can you?

SELECT "Fred" AS Name FROM tblMonths
UNION ALL SELECT "Joe" AS Name FROM tblMonths;
 
K

KARL DEWEY

Your union query is not required to pull any data from the table.
Maybe you want something like this that does not need a union query --

SELECT tblMonths.*
FROM tblMonths
WHERE Name = "Joe" OR Name = "Fred";
 
B

Bob Barrows

AndyK said:
Can you?

SELECT "Fred" AS Name FROM tblMonths
UNION ALL SELECT "Joe" AS Name FROM tblMonths;

Is the idea to get 12 rows with "Fred" in them and 12 with "Joe"?

The only possible issue I see is using the reserved keyword "Name" as your
column alias (btw, you only need to use the alias in the first query - the
rest of the queries in a union take the column names from the first query).
Perhaps it would help if you clued us in on whatever symptom is making you
think there is something "wrong" with this query. We're not psychics, you
know :)
 
A

AndyK

Bob thanks for the response, agree re complete lack of information from me!

OK - I am after two rows and one column of output which looks like

Fred
Joe

All my data will be literal - I am only using tblMonths as I believe I have
to quote some table or query as input even if as in this case none of my data
is in it.

Have this morning discovered that this works fine in Access 2007 but my
problem is with Access 2003 - this is my target version. In 2003 it returns
no data....?

Thanks for any further input.
 
B

Bob Barrows

Is there at least one record in tblMonths? There needs to be a record if the
query is going to return anything.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top