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_id | Name | Salary |
|---|---|---|
| E001 | chandan | 25000 |
| E002 | Adhiraj | 35000 |
Consider the below table :Company_Asset
| Emp_id | Name | |
|---|---|---|
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_id | Name |
|---|---|
| E001 | chandan |
| E002 | Adhiraj |
No comments:
Post a Comment