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

  • Thread starter Thread starter AndyK
  • Start date Start date
A

AndyK

Can you?

SELECT "Fred" AS Name FROM tblMonths
UNION ALL SELECT "Joe" AS Name FROM tblMonths;
 
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";
 
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 :-)
 
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.
 
Is there at least one record in tblMonths? There needs to be a record if the
query is going to return anything.
 
Back
Top