What is the SQL INSERT INTO SELECT Statement and how it can be used with the database?
The SQL INSERT INTO SELECT statemet is used to insert new data in to the database using SELECT Statement.
SQL INSERT INTO SELECT Statement Example:
Assume that you have a table 'customer' in your database.
||123 xyz street
||456 abc street
||789 pqr street
You just want to add new customer to the database in another table 'customer2' from customer. You have following columns on the table: name, email, phone. Use following syntax of sql insert into select statement for that case:
INSERT INTO customers2 (name, address, email, phone)
SELECT name, address, email, phone FROM customers;