INSERT INTO
as_dict.object_column_entity_relation (object_column_id, entity_relation_id)
SELECT
oc.object_column_id,
er.entity_relation_id
FROM
as_dict.object_column oc,
as_dict.entity_relation er,
information_schema.columns isc
WHERE
oc.column_name = isc.column_name AND
er.object_schema = isc.table_schema AND
er.object_name = isc.table_name AND
NOT EXISTS (
SELECT
ocer.object_column_entity_relation_id
FROM
as_dict.object_column_entity_relation ocer
WHERE
ocer.object_column_id = oc.object_column_id AND
ocer.entity_relation_id = er.entity_relation_id
);