I need to convert a table redeem to include a date that will be populated from blah, but it doesn't exist as of right now.
I need to SELECT all of the rows in the redeem table where pay autokey matches the redeem.pay. The blah.number is included in the pay table and in blah I want to get the blah.date. Then I need to set it to the redeem.date and make sure that the redeem.days_redeemed is not equal to 0.
UPDATE redeem
SET redeem.date =(SELECT blah.date
FROM blah
INNER JOIN pay ON pay.number = blah.number
INNER JOIN redeem ON redeem.pay = pay.autokey
WHERE redeem.days_redeemed <>0)
This is the error I receive: You can't specify target table 'redeem' for update in FROM clause
How do I go about doing this in MySQL in one SQL statement?