August 21, 2008 at 8:24 am
I have written this UNION query below and it is running without any errors. The problem I'm running into is when I try to export this to a .CSV file. I get the following error:
"The number of columns in the two selected tables or queries of a union query do not match"
Has anyone ever run into this before?
SELECT 'N','08/21/08' as Update_Date,'08/21/08' as Create_Date,'Company1' as Catalog_Name, Left([Prod Cat],1) as Node, [LEVEL 1] as ctgname, 1 as seq, 'Company1' as ctgparentlvl1
FROM [eStorefront Master]
UNION
SELECT 'N','08/21/08','08/21/08','Company1', Left([Prod Cat],2), [Level 2], 2, Left([Prod Cat], 1)
FROM [eStorefront Master]
UNION
SELECT 'N','08/21/08','08/21/08','Company1', [Prod Cat], [Level 3], 3, Left([Prod Cat], 2)
FROM [eStorefront Master]
ORDER BY seq, ctgparentlvl1, ctgname;
August 21, 2008 at 9:19 am
Whoops hang on a mo....
August 21, 2008 at 9:31 am
Thanks for the reply but there are actually 8 lines in that second select statement.
The problem was occurring because I originally did have mismatched numbers of columns. I fixed this but didn't save it. So it would run but not export without me saving the query.
:rolleyes:
August 21, 2008 at 9:36 am
Sorry i thought i had it for a moment.. I have tested this on my machine without a problem
I can think of two possible work arounds -bearing in mind i can't reproduce the problem so i can test these ideas - that might help.
1. Save this query and use it as the source of a second select query and export from that.
2. Save this query and use it as a source for a make-table query or append query, export from the table.
I'll keep looking in the mean time.
K.
August 21, 2008 at 9:37 am
smick (8/21/2008)
Thanks for the reply but there are actually 8 lines in that second select statement.The problem was occurring because I originally did have mismatched numbers of columns. I fixed this but didn't save it. So it would run but not export without me saving the query.
:rolleyes:
Yep noticed a "hidden" 2 hence the apology
August 21, 2008 at 9:39 am
The 2nd and 3rd select statement omit "ctgparentlvl1". If you add that or a null, the error should be resolved.
August 21, 2008 at 9:41 am
This issue is solved, I just had to save the query with the changes I made before attempting to export.
Apparently you can run a query after fixing errors without saving but not export without saving your corrections.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy