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
Any ideas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.Produc tid
WHERE OLDp.Productid IS NULL
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.Produc
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.
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.