Joining data from two tables in MySQL (running MAMP on Mac)

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)

write the equivalent SELECT statement, then do an EXPLAIN on it

are there any indexes on the tables?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.