Link to home
Start Free TrialLog in
Avatar of cano63
cano63

asked on

Add record to a table from other table

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

Avatar of TheSloath
TheSloath

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.
ASKER CERTIFIED SOLUTION
Avatar of puppydogbuddy
puppydogbuddy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.