We need a MySQL Stored Procedure to process the results of a query, and for each result, add records to 2 other tables.
We have a table of accounts, and a set of new accounts returned by a query. For each new account, there are one or more existing accounts that are related to it, that have information that we'd like to copy in as we add the new accounts to the table of accounts.
Here are the designs of the tables involved:
new accounts (returned by a query)
So we'd like a stored procedure that can do the following:
1. Start with a query that returns a set of new accounts
2. For each new account, there should be at least 1 existing account record. Find one record of an existing account
3. create a new record in the accounts table, using the information for the new account in some fields, and information from the existing account record in other fields. The id of this record should be set by auto_increment.
4. the existing account will have 0 or more records in the accounts_nodes table. For each, create a new record in the accounts_nodes table, with the account_id of the new account record, and the node_id from the accounts_nodes record.
The stored procedure should be developed for MySQL 5, and be clearly documented and commented.
Please respond with a sample of a MySQL Stored Procedure that you have developed to show a your coding ability and clear documentation ability.
15 freelancer bu iş için ortalamada 141$ teklif veriyor
I am from CapMinds Technologies located in DC Metro with delivery center in India.I would like to work on this project. Our dedicated team is available for 24/7 round the clock support.