Events from my database bd_yellowbox
should be added to the database groupofficecom
. The data of one event in bd_yellowbox
is stored in three attributes tables element
, actions
, and actionsparam
. All three tables have one column in common, ID_ELEMENT
. The column has the same value in all three tables for one data point.
The data of one event in groupofficecom
is stored in two tables, cal_events
and cf_cal_events
. The primary key of cal_events
is id
and is auto incremented. The primary key of cf_cal_events
is model_id
and is NOT auto incremented.
cf_cal_events.model_id = cal_events.id
The two databases are linked through a column in the table cf_cal_events
:
cf_cal_events.col_10 = bd_yellowbox.element.ID_ELEMENT
Here's my original code:
REPLACE INTO groupofficecom.cal_events (data1,data2)
VALUES ('1','Tom Hanks')
REPLACE INTO groupofficecom.cf_cal_events (model_id, col_10)
SELECT groupofficecom.cal_events.id, bd_yellowbox.element.ID_ELEMENT
FROM bd_yellowbox.element, groupofficecom.cal_events
WHERE bd_yellowbox.element.ID_ELEMENT=bd_yellowbox.actions.ID_ELEMENT
AND bd_yellowbox.element.ID_ELEMENT=bd_yellowbox.actionsparam.ID_ELEMENT;
Problem #1: the insertion of data in cf_cal_events
is resulting in one event being inserted as multiple events with different IDs.
Problem #2: when I re-execute the query, the events are re-inserted into both tables as new events. This creates new id
s because of the AUTO_INCREMENT of cf_events.id, which prevents changed events from being updated in the bd_yellowbox
database.
THANK YOU ALL!