MainMenu

Home Java Overview Maven Tutorials

Sunday 15 January 2017

Copy Rows from one table to another

How do you copy rows from one table to another


Syntax :
INSERT INTO table2 (column names)
Select column Name from table1;
Consider Below tables :
Consider the below table :Employee
Emp_idNameSalary
E001chandan25000
E002Adhiraj35000

Consider the below table :Company_Asset
Emp_idName

Now if you want to copy the data from table Employee and insert copied data in table Company_Asset Then Query will be :


Query to copy data from a table & insert it another table


INSERT INTO Company_Asset (Emp_id, Name)
Select Emp_id, Name
from Employee
Result :
Emp_idName
E001chandan
E002Adhiraj

SQL Query to insert data of one table to another table,Use of INSERT INTO SELECT statement

No comments:

Post a Comment