SELECT and INSERT
This lesson discusses inserting data into a table using SELECT and INSERT in a single query.
We'll cover the following...
SELECT and INSERT
MySQL provides us the facility to insert several rows from another table into an existing table using a combination of select and insert statements. In fact, we can also create a table on the fly and fill it up with rows from another table.
Syntax to Insert in an Existing Table
INSERT INTO table1 (col1, col2)
SELECT col3, col4
FROM table2;
Syntax to Insert in a New Table
CREATE TABLE newTable (col1 <datatype>, <col2>)
SELECT col3, col4
FROM table2;
Connect to the terminal below by ...
Access this course and 1400+ top-rated courses and projects.