Inserting data using query: – Whenever the user wants to transfer data from one table to another table, the insert statement is used irrespective of data which may be in processed or unprocessed form. While using the insert statement, help of select statement is taken. The select statement decide which row are too we transferred. Some example of insert statement with query.

                Insert into company(ename) select ename from employee;

Here, ename column from table employee transferred to ename column in table company.

                Insert into company(ename,salary) select ‘Rakesh’,AVG(salary) from employee where city=’Telco’;

Insert ename and salary column from table employee to table company of only those rows which name as and the salary which is equal to average salary of table employee which city is Telco.

Advertisements