I have been trying to update a date for all rows in a table by 11 days using a correlated subquery. One problem I have run into is that MySql will not let me update the table I am selecting from in my subquery. I was able to work around that by saving the results from the subquery as a temporary table. This works when I have a defined value for my where clause in the subquery. However, when I try to reference the outer query (ie: vm.psname = v.psname) I get "unknown column 'v.psname' in 'where clause' here is my query:
UPDATE cloud.vms v SET expirationdate=(
SELECT date FROM (
SELECT DATE_ADD(
(SELECT expirationdate
FROM cloud.vms vm
WHERE vm.psname=v.psname),
INTERVAL 11 DAY)
AS date)
AS tmptbl)
I have also looked at using an inner join (example from previous post). However, I am not sure how to do this.