473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

UNION query not working

If I run the following query in Access 2002 then I get the expected
result:

SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get the contents of both tables with no duplicates. If I add INSERT
INTO, then it doesn't work:

INSERT INTO AssetControl
SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get an error "Syntax error in FROM clause" and it highlights the word
UNION. I have no idea why this isn't working!

Any help would be much appreciated.

Mark

Feb 1 '06 #1
4 7785
<sp**@pinkdoggy.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
If I run the following query in Access 2002 then I get the expected
result:

SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get the contents of both tables with no duplicates. If I add INSERT
INTO, then it doesn't work:

INSERT INTO AssetControl
SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get an error "Syntax error in FROM clause" and it highlights the word
UNION. I have no idea why this isn't working!


AIUI union queries aren't updatable.

Keith.
www.keithwilby.com
Feb 1 '06 #2
<sp**@pinkdoggy.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
If I run the following query in Access 2002 then I get the expected
result:

SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get the contents of both tables with no duplicates. If I add INSERT
INTO, then it doesn't work:

INSERT INTO AssetControl
SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get an error "Syntax error in FROM clause" and it highlights the word
UNION. I have no idea why this isn't working!

Any help would be much appreciated.

Mark

Use an alias, U for the union query:

INSERT INTO AssetControl
SELECT U.* FROM
(SELECT * FROM CSVImport
UNION
SELECT * FROM AssetTemp) AS U
The Access query editor may re-write this - note the final dot after the
last square bracket

INSERT INTO AssetControl
SELECT U.* FROM
[SELECT * FROM CSVImport
UNION
SELECT * FROM AssetTemp]. AS U
Other options include saving the union bit as a saved query, and basing your
insert query on this query (rather than the all-in-one solution proposed
above). Another thing to consider would be doing the two inserts separately
and wrapping them in a transaction.


Feb 1 '06 #3

"Keith Wilby" <he**@there.com> wrote in message
news:43**********@glkas0286.greenlnk.net...
<sp**@pinkdoggy.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
If I run the following query in Access 2002 then I get the expected
result:

SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get the contents of both tables with no duplicates. If I add INSERT
INTO, then it doesn't work:

INSERT INTO AssetControl
SELECT *
FROM CSVImport
UNION SELECT *
FROM AssetTemp;

I get an error "Syntax error in FROM clause" and it highlights the word
UNION. I have no idea why this isn't working!


AIUI union queries aren't updatable.

Keith.
www.keithwilby.com

Nobody is trying to update the union query, merely to take the records it
returns and whack them into another table.
Feb 1 '06 #4
"Anthony England" <ae******@oops.co.uk> wrote in message
news:dr*********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...

Nobody is trying to update the union query, merely to take the records it
returns and whack them into another table.

I really should stop trying to read in fast-forward mode.
Feb 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: s_gregory | last post by:
The mdb is considerable size 70 +- mb. A complex union query was working well, but when an additional union select... was added into the query, selecting identical fields from a different source,...
4
by: Missy | last post by:
We’ve recently upgraded our computer system to XP. My union query (which was working perfectly for years) now returns hieroglyphics instead of invoice numbers. When I run the 2 queries...
0
by: jimmyshaw83 | last post by:
I am sorry if this topic is tired, but after all that I have read I am still in the woods here. I have built a database to handle weekly and monthly reports of what people are doing. They submit...
12
by: Susan Bricker | last post by:
For those of you who have been following my posts - they all pertain to a Dog Competition Organization's Database. There are three classes that the dogs can participate: NOVICE, OPEN, and...
2
by: S. van Beek | last post by:
Dear reader, The following code delivers a wild card in the result of the query. But the ORDER BY is not longer working.
3
by: mikes | last post by:
I have 2 separate queries, which effectively are the same except they draw data from separate tables. Both tables are (design-wise) identical, only the data is different. for each query, there are...
7
by: KoliPoki | last post by:
Hello every body. I have a small issue. Problem: I have a table with 4 descriptor columns (type). I need to formulate a query to retrieve a count for each type so I can group by...etc. The...
27
by: MLH | last post by:
How can I turn the following into a make-table query? SELECT & " " & AS Recipient FROM tblVehicleJobs INNER JOIN tblAddnlOwnrs ON tblVehicleJobs.VehicleJobID = tblAddnlOwnrs.VehicleJobID WHERE...
1
by: kigoobe | last post by:
Hi friends, I'm having three queries that works perfectly ... SELECT ib.id as id, ib.titre as title, ib.date_expire as date_fin, ib.created_at as date_creation, eb.content as content, '' FROM...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.