MySQL Update from Select
I’ve just wanted to update the table’s field from the SELECT based on the other table including grouping and aggregate function. In my case, I need to update a TIMESTAMP field in tableA based on selected TIMESTAMP field from the tableB.
1 2 3 4 5 |
UPDATE tableA SET timestampFieldA = (SELECT MAX(timestampFieldB) FROM tableB WHERE tableA.id=tableB.tableAId GROUP BY tableB.tableAId) |