This is a very simplified graphical situation of the matter: https://i.stack.imgur.com/5NoRe.png
There are two DBs in different schemas, the old yellow one (one simple and plain table) and the new green one (with some relations like the one described above).
The matter is that I want to migrate the info on the OldDB (over 40k rows) into the NewDB and I’m stucked with this relationship transformation. In the OldDB we had different fields for each center and depending on if their CHAR(1) = Y or = N, they were under some action or not.
Now in the NewDB we have those centers in another table with their own id, and related with a Many to Many to the main table (b).
So what I want is to go through each single center in the Old.DB (up to 20) and when it turns to be for example center14 CHAR(1) = Y, to set the NewDB.center_has_b.center_id = 14 and NewDB.center_has_b.b_id = OldDB.oldb.oldb_id.
I’m a newbie in MySQL but I was thinking on doing something like this, with no luck:
INSERT NewDB.center_has_b (center_id, b_id) (N, (SELECT oldb_id from OldDB.oldb WHERE centerN = 1));
try this:
EDIT: This is based on the first comment for this answer