473,405 Members | 2,415 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,405 software developers and data experts.

Append only new results to a table from a query - how?

Hi,

I've been searching and trying and I'm nearing the end of my patience :\

What I would like to do is to dump the results of a query (just an ID number, in my case) into a table. If the ID number already exists in the table, I would not like it to be added.

Seems so simple, yet I'm stumped and frustrated.

Would anyone be so kind to help?

Thank you!
Feb 26 '08 #1
3 7902
ADezii
8,834 Expert 8TB
Hi,

I've been searching and trying and I'm nearing the end of my patience :\

What I would like to do is to dump the results of a query (just an ID number, in my case) into a table. If the ID number already exists in the table, I would not like it to be added.

Seems so simple, yet I'm stumped and frustrated.

Would anyone be so kind to help?

Thank you!
It is a lot simpler than you realize. I'm assuming that the [ID Number] is Unique which usually is the norm for IDs. Simply make the [ID Number] in the Table the Primary Key for the Table, if you already have a Primary Key defined for the Table, make the [ID Number] Field Indexed/No Duplicates. When you dump (Append) the ID Numbers from the Query to the Table, if they already exist, they will not be Appended.
Feb 26 '08 #2
Success!!

Thanks so much. Answer was right in front me!
Feb 26 '08 #3
NeoPa
32,556 Expert Mod 16PB
That's a good solution for relatively small queries, or for where the matched (pre-existing) items are small in number (and is a very handy technique to know about), but it's more efficient to write the selection criteria into the SQL itself such that it doesn't even try to add the matching records (thereby reducing the extra overhead).

EG to add IDs from table [A] into table [b] (where ID is unique key - or otherwise) :
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [b] ([ID])
  2. SELECT A.ID
  3. FROM [A] LEFT JOIN [b]
  4.   ON A.ID = B.ID
  5. WHERE B.ID IS NULL
Mar 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: JD | last post by:
I'm using MS Access 97 in an XP environment. I have an append query at the top of a query tree that is behaving strangely. From design view, I can choose view datasheet - and I see one set of...
2
by: Danny | last post by:
I want to extract a subset of fields from one table into another the master table has many fields the subset has about half, but still many. Is there a way I can just append the master into the...
2
by: anita | last post by:
I am sorry if this sounds as a silly problem. I have table 1 with 10 records and table 2 with 20 records. I want to append 20 records from Table 2 to table 1. But when I run the append query, the...
1
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to...
2
by: Mark | last post by:
I have a FE/BD 2002 DB on a XP pro platform. I know this is ugly but it works for me...... A text file is produced from our Oracle WMS. (Average 20k records) A command button deletes all records...
4
by: MN | last post by:
I have to import a tab-delimited text file daily into Access through a macro. All of the data needs to be added to an existing table. Some of the data already exists but may be updated by the...
0
by: Starke | last post by:
I have the below code, and i need to append the results to a local table called "tblUserInfo" . The local table, tblUserInfo has the same data structure as the results. But not sure how to append...
14
by: Supermansteel | last post by:
My team at work uses Cognos to run multiple queries to pull in data. Then they take that data and import into Access and then usually run an Append Query to run a RND function to pull out a few...
4
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
1
by: chaurous | last post by:
hi guys, i have a problem of building a function and from the result i should append the results to another table. function required: my first idea is query but it is not working. how should...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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,...

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.