Link to home
Start Free TrialLog in
Avatar of Patrick O'Dea
Patrick O'DeaFlag for Ireland

asked on

SQL - Insert Where Not Already Exists

Hi,
Struggling with my SQL again,

I am loading new data into tblPrices from tblPasteForLoad

The tblPrices table has a compound key consisting of   SupplierID and ProductCode.

INSERT INTO tblPrices (SupplierID, ProductCode)
SELECT SupplierID,ProductCode from tblPasteForLoad
WHERE
tblPasteForLoad.SupplierID & tblPasteForLoad.ProductCode
NOT EXISTS IN tblPrices

Hopefully the above 5 lines of pseudo SQL will indicate the SQL I actually require.

Thankyou!









ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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 your compound key is 'unique' you can just use 'INSERT IGNORE':

INSERT IGNORE INTO tblPrices (SupplierID, ProductCode) VALUES ....

Open in new window

Avatar of Patrick O'Dea

ASKER

Thanks Angel with 4 l's!

Just perfect!