If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Can't see what is wrong with this Union query...
Can you?
SELECT "Fred" AS Name FROM tblMonths UNION ALL SELECT "Joe" AS Name FROM tblMonths; |
#2
|
|||
|
|||
Can't see what is wrong with this Union query...
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"; -- Build a little, test a little. "AndyK" wrote: Can you? SELECT "Fred" AS Name FROM tblMonths UNION ALL SELECT "Joe" AS Name FROM tblMonths; |
#3
|
|||
|
|||
Can't see what is wrong with this Union query...
AndyK wrote:
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 :-) -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" |
#4
|
|||
|
|||
Can't see what is wrong with this Union query...
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. "Bob Barrows" wrote: AndyK wrote: 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 :-) -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" . |
#5
|
|||
|
|||
Can't see what is wrong with this Union query...
Is there at least one record in tblMonths? There needs to be a record if the
query is going to return anything. AndyK wrote: 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. "Bob Barrows" wrote: AndyK wrote: 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 :-) -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" . -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" |
#6
|
|||
|
|||
Can't see what is wrong with this Union query...
Bob
You are spot on, I added a record to tblMonths and it works - thank you! "Bob Barrows" wrote: Is there at least one record in tblMonths? There needs to be a record if the query is going to return anything. AndyK wrote: 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. "Bob Barrows" wrote: AndyK wrote: 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 :-) -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" . -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" . |
Thread Tools | |
Display Modes | |
|
|