1INSERT INTO table
2(column1, column2, ... column_n )
3VALUES
4(expression1, expression2, ... expression_n );
1INSERT INTO my_table SELECT * FROM source_table;
2INSERT INTO my_table (a, b, c) SELECT a, b, c FROM source_table;
3INSERT INTO my_table (a, b, c) SELECT a, b, c FROM source_table s
4 WHERE s.my_col >= 10;
1INSERT INTO table
2(column1, column2, ... column_n )
3SELECT expression1, expression2, ... expression_n
4FROM source_table
5[WHERE conditions];
1INSERT INTO table
2(column1, column2, ... column_n )
3SELECT expression1, expression2, ... expression_n
4FROM source_table
5[WHERE conditions];
6
7-- Basically, omit the VALUES clause when using SELECT for an insert into.
1Let’s assume that, we have our employee table.
2We have to copy this data
3into another table. For this purpose,
4we can use the INSERT INTO SELECT
5operator. Before we go ahead and do that,
6we would have to create another
7table that would have the same structure
8as the given table.
9• First create the second table with
10the same table structure with copied one.
11• Then use the syntax:
12Let’s say employee_duplicate is New table
13employee is First table that we want to copy it into new table
14
15INSERT INTO employee_duplicate SELECT * FROM employee;