I am trying to do an UPDATE query by using the data from a SELECT query.
I have a table called "Customer" which has several fields (ToDo, CustomerID, AddressType, CustomerName, StreetAddress,City,...). One of the fields (ToDo) may have a value of "UPDATE". I need to run a query that goes through this table and then finds all the records that have that value (UPDATE) in the ToDo field and then update all the records in the table "Address" that match the CustomerID and AddressType.
I believe that the SELECT statement to get the data would look something like this:
And the UPDATE query would look something like this:
I am having trouble troubleshooting the syntax and putting the two together. Can this even be done?
mafhobb
I have a table called "Customer" which has several fields (ToDo, CustomerID, AddressType, CustomerName, StreetAddress,City,...). One of the fields (ToDo) may have a value of "UPDATE". I need to run a query that goes through this table and then finds all the records that have that value (UPDATE) in the ToDo field and then update all the records in the table "Address" that match the CustomerID and AddressType.
I believe that the SELECT statement to get the data would look something like this:
Code:
"SELECT Customer.customerId, Customer.addressNr, Customer.addressType, Customer.firstname, Customer.lastname, Customer.companyName, Customer.postalcode, Customer.country, Customer.workphone, Customer.email, Customer.notes, Customer.streetaddress, Customer.city, Customer.contactTypeId " & _
"FROM Customer " & _
"WHERE (Customer.ToDo='UPDATE');"
And the UPDATE query would look something like this:
Code:
"UPDATE Address SET Customer.addressNr,Customer.firstname, Customer.lastname, Customer.companyName, Customer.postalcode, Customer.country, Customer.workphone, Customer.email, Customer.notes, Customer.streetaddress, Customer.city, Customer.contactTypeId" & _
"WHERE Address.CustomerID=Customer.CustomerID AND Address.AddressType=Customer.addresstype;"
I am having trouble troubleshooting the syntax and putting the two together. Can this even be done?
mafhobb