here's how i do it:
create a temporary table to store aggregated values
CREATE TEMPORARY TABLE tmp_operation
SELECT id, MIN(`column`) as cln FROM table2 GROUP BY id;
add an index to the temporary table for quick connection to table 1 (you can omit this step depending on the size of the data)
ALTER TABLE tmp_operation ADD UNIQUE INDEX (id);
update with a simple connection. you can use left or inner join depending on whether you want to update columns to zeros)
UPDATE table1
SET table1.`column` = tmp_operation.cln
INNER JOIN tmp_operation ON table1.id = tmp_operation.id;
delete temporary table after execution
DROP TABLE tmp_operation;
frail source
share