Refresh request:
update table1 firstInstance, tabe1 secondInstance set firstInstance.column_B = (IF(sIFNULL(secondInstance.column_B,0) + 12 >= 0, IFNULL(secondInstance.column_B,0) + 12, 0) +firstInstance.column_A) where DATEDIFF(secondInstance.date, firstInstance.date) = 1;
SELECT query:
SELECT firstInstance.DATE, firstInstance.COLUMN_A, (IF(IFNULL(secondInstance.column_B,0) + 12 >= 0, IFNULL(secondInstance.column_B,0)+ 12, 0) +firstInstance.column_A) AS COLUMN_B FROM table1 firstInstance LEFT JOIN tabe1 secondInstance ON DATEDIFF(secondInstance.date, firstInstance.date) = 1;
source share