Created
April 28, 2014 20:29
-
-
Save matthewpoer/11383096 to your computer and use it in GitHub Desktop.
SugarCRM: MySQL Script will Update Contacts' Assigned User and Teams to copy from their parent Accounts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| update contacts | |
| join ( | |
| select accounts.id as accounts_id,accounts.assigned_user_id as accounts_assigned_user_id, | |
| accounts.team_id as accounts_team_id,accounts.team_set_id as accounts_team_set_id, | |
| contacts.id as contact_id,contacts.assigned_user_id as contacts_assigned_user_id, | |
| contacts.team_id as contacts_team_id,contacts.team_set_id as contacts_team_set_id | |
| from accounts | |
| join accounts_contacts on accounts.id = accounts_contacts.account_id | |
| join contacts on contacts.id = accounts_contacts.contact_id | |
| where accounts.deleted=0 and contacts.deleted=0 and accounts_contacts.deleted=0 | |
| ) as tmp on contacts.id = tmp.contact_id | |
| set contacts.assigned_user_id = tmp.accounts_assigned_user_id, | |
| contacts.team_id = tmp.accounts_team_id, | |
| contacts.team_set_id = tmp.accounts_team_set_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment