phpmyadmin - MySQL: Copy data from TableA:FieldA to TableB:FieldB matching common UID field -
i didn't see exact question asked. people seem want sync. need one-time copy.
mysql version 5.5.35.
in mysql database need one-time copy data tablea:fielda tableb:fieldb while matching common uid field — tablea:uid , tableb:uid related fields.
more copying employee id 1 table different field in table, , both tables have contact id in common. need tablea:uid=1's employee number appear in tableb on correct row tableb:uid=1.
thanks.
updated: tested solution, got error 1442
update civicrm_value_member_fields_1 set civicrm_value_member_fields_1.aft_id_43 = (select civicrm_contact.external_identifier civicrm_contact civicrm_contact.id = civicrm_value_member_fields_1.entity_id)
alt version of above:
update `civicrm_value_member_fields_1` set `aft_id_43` = (select `external_identifier` `civicrm_contact` `id` = `entity_id`)
both error 1442:
#1442 - can't update table 'civicrm_contact' in stored function/trigger because used statement invoked stored function/trigger.
the following example should help.
create table a(id int,cid int); create table b(id int,cid int); insert values(6,1); insert values(7,2); insert values(8,3); insert values(9,4); insert b(cid) values(1); insert b(cid) values(3); insert b(cid) values(4);
table a
| id | cid | |----|-----| | 6 | 1 | | 7 | 2 | | 8 | 3 | | 9 | 4 |
table b
| id | cid | |--------|-----| | (null) | 1 | | (null) | 3 | | (null) | 4 |
the update
query update b's id
field referring a's id
field.
update b set b.id = (select a.id a.cid = b.cid);
table b
| id | cid | |----|-----| | 6 | 1 | | 8 | 3 | | 9 | 4 |
Comments
Post a Comment