Solved

Add record to a table from other table

Posted on 2007-03-25
4
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

752 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