INSERT INTO SELECT
In order to insert data from one table to another table we use the below query:
INSERT INTO DummyTable (First_Name, Last_Name)
SELECT First_Name, Last_Name
FROM EmployeeName
WHERE Salary = 20000
If columns listed in insert clause and select clause are same, we do not need to list them.
With "INSERT INTO SELECT" you can insert many rows at a time. This can be used if we want to insert values into our table by selecting these from:
1. Another table in our database
2. A totally different database on the same server
3. From the same table etc.
No comments:
Post a Comment