I apologize for asking a question that has been presented all too many times. However, after reading several threads and google hits, I can't figure out what I am doing wrong.
I have two tables, a customer table and an inquiry table. I need to update customer records based on a value in the inquiry table. My SQL looks like this:
I have tried other variations of this, such as:
But no matter what I do, all records in the customers table are getting updated. How can I limit the update based on the join condition and the where clause?
Any help would be appreciated.
-Kevin
Kevin Davie
Consultant
Sogeti USA
I have two tables, a customer table and an inquiry table. I need to update customer records based on a value in the inquiry table. My SQL looks like this:
Code:
UPDATE Customers
SET opt_in_contact = 'N',
opt_in_mail = 'N',
opt_in_email = 'N'
FROM Customers INNER JOIN Inquiries ON Inquiries.is_customer_id = Customers.is_customer_id
WHERE Inquiries.inquiry_type = 'un-subscription'
I have tried other variations of this, such as:
Code:
UPDATE Customers
SET opt_in_contact = 'N',
opt_in_mail = 'N',
opt_in_email = 'N'
FROM Inquiries
WHERE Customers.is_customer_id = Inquiries.is_customer_id AND Inquiries.inquiry_type = 'un-subscription'
But no matter what I do, all records in the customers table are getting updated. How can I limit the update based on the join condition and the where clause?
Any help would be appreciated.
-Kevin
Kevin Davie
Consultant
Sogeti USA