Solved

Add record to a table from other table

Posted on 2007-03-25
4
235 Views
Last Modified: 2008-02-01
I have this two tables , products and new products, in new products i enter the new products that i receive , this products don't exist in products table, i want to run a sql query that add all this record to the product table.
Any ideas

0
Comment
Question by:cano63
4 Comments
 
LVL 9

Expert Comment

by:TheSloath
ID: 18789606
Create a new query and add your 'New Products' table.
Change the query's type on the Query Menu to 'Append'.
Add the fields from the 'New Products' table you wish to add to the Products tale, and select the field in the Products table you wish each field from the New Products table to be added to.
0
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 125 total points
ID: 18789624
Dim sSQL As String

sSQL = "INSERT INTO tblProducts "
sSQL =  sSQL & "Select * "
sSQL =  sSQL &  "From [tblNewProducts] ;"

Current db.Execute sSQL, dbFailOnError
0
 
LVL 9

Expert Comment

by:dbeneit
ID: 18790052
If you want to insert those products than they are new and not insert olds:
INSERT INTO  products (Productid, [ other  list fields])
select NEWp.Productid,  NEWp.[other  list fields]   from NEWproducts NEWp  left join products OLDp on NEWp.Productid=OLDp.Productid
WHERE OLDp.Productid IS NULL
0
 
LVL 44

Expert Comment

by:GRayL
ID: 18790067
I guess I have to ask, why two tables?  If you had a boolean field named KeepYN (default=No), on a regular basis, you could query all the No records and 'decide' which ones to 'Keep'.  Just another way of looking at it.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now