I have two tables basic_data_1
and basic_data_2
. Each has a field identifier
. I want to update the data from basic_data_2
into basic_data_1
. I am writing the following query.
UPDATE basic_data_1 b1
INNER JOIN basic_data_2 b2
ON b1.identifier = b2.identifier
SET b1.hh_size = b2.hh_size, b1.hh_type = b2.hh_type;
This query keeps on running (I guess there is some error which leads to an infinite loop!)
If I add the clause WHERE b1.identifier = (SELECT identifier FROM basic_data_1);
, I get the following error:
ERROR 1093 (HY000): You can't specify target table 'b1' for update in FROM clause
.
Basically I need all matching rows updated. Can someone help my update my query?
(Note: Both tables have around 100000 rows)