Friday, January 16, 2015

SQL: INSERT by copying values from two tables - Insert in combination of Select

Your Sweet Fruit company just acquired another Fruit company. You hired a new manager to be the contact person for the orders in the newly acquired company. And you want to migrate the Fruit data from the acquired company to your central database.

You can use the following SQL to do the job.

INSERT INTO FRUIT (NAME, PRICE, ORDER, CONTACT)
SELECT unique NAME, PRICE, ORDER, empName || ' ' || empPhone
FROM legacy_fruit, EMPLOYEE
WHERE empID = 100099887;


References

1. SQL: INSERT by copying values of existing columns of a table - Insert in combination of Select
2. SQL: INSERT by copying values from existing records for some columns and using other values for other columns - Insert in combination of Select


                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment