Insert Into SQL Statement Help!

bmcgree1

Registered User.
Local time
Yesterday, 21:27
Joined
Jun 19, 2009
Messages
43
So I have 2 tables and I want to Insert only 1 value into my second table as long as it doesn't exist.
So if 'LeaseID' in table1 = 201 then I want to insert 'LeaseID' into table2 only if the value 201 does not exist in table2. If it does exist then my statement should "attempt to update 0 records" if ran.

How do I write that WHERE clause? I pasted what I was attempting to make work below.

Thank you very much!

INSERT INTO tbl_Renter ( LeaseID ) SELECT tbl_Lease.LeaseID FROM tbl_Lease WHERE (((tbl_Lease.LeaseID)=[forms]![frm_Lease].[leaseID])) And tbl_Renter.LeaseID!=forms!frm_Lease.leaseID;
 

Users who are viewing this thread

Back
Top Bottom