473,748 Members | 9,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7824
<sp**@pinkdoggy .net> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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.goo glegroups.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.gr eenlnk.net...
<sp**@pinkdoggy .net> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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
3958
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, it began to have problems. Failure was observed only in a few PC's at first. For example, in an NT 4.0 SP6 PC, it continued to work OK. But in my Win 2k laptop, it failed. As the union query was gradually simiplified in testing, the failure...
4
1938
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 separately (of which the Union query is made up of) they return numbers perfectly. Can you please help? The Union Query looks like this: SELECT * FROM UNION SELECT * FROM ;
0
1604
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 what they are working on and then you input a date and the info is narrowed allowing a report to be created containing all of the memo fields submitted during those dates. My Source Query gets all the memo fields in their entirety (greater than...
12
2913
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 UTILITY. I want to produce a report of the top 10 average scores for each class for each year.
2
4599
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
2223
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 2 tables with a standard LEFT JOIN. One field of the query is calculated, looking for a NULL in one table, and then using a field from the second table in that case. One query looks like this: PARAMETERS Text ( 255 ); SELECT...
7
3317
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 view I have works, but doesn't work when I supplement the query with some functions... they just don't like the UNION. The real problem is I can't change any of the udf's or queries, just the view. The view is inner joined back on to the primary...
27
13807
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 tblVehicleJobs.VehicleJobID=GetCurrentVehicleJobID(); UNION SELECT AS Recipient FROM tblVehicleJobs INNER JOIN tblLienHolders ON tblVehicleJobs.VehicleJobID = tblLienHolders.VehicleJobID WHERE
1
2188
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 tbl_announce AS ib LEFT JOIN tbl_announce_content AS eb ON ib.id = eb.rap_id WHERE ib.lang = 'fr' AND ( ib.date_expire = '0000-00-00' OR ib.date_expire >= '2008-02-01' )
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.