I am trying to update 3 different columns in a table based on three different conditions in a where clause. (I have updated data in another table, so I join them on primary keys)
For example, if before I did not have a value in field1 for the client, but now I do it, I should be able to update the field "field1". Similarly, I would like to update the columns field2 and field3.
Can I do this in one update.
To update a single column, you can write something like the following:
Update tblCustomer SET tblCustomer.Order_Date = tblCustomerInfo.Order_Date FROM tblCustomer LEFT JOIN tblCustomerInfo ON (tblCustomer.CustomerID = tblCustomerInfo.CustomerID) WHERE tblCustomer.Order_Date <> tblCustomerInfo.Order_Date AND tblCustomer.Order_Date is NULL;
How about updating 3 different columns in one pass based on different conditions (if there was no data for the fact that this column was previously absent, and now it is available)
source share