SQL SELECT INTO

The SELECT INTO command allows you to insert the results of a query into another table.

-- Works in PostgreSQL, MySQL, SQL Server, and Oracle insert into buildings_on_main_st select * from buildings where address like '%Main St';

Assume we have an empty table buildings_on_main_st. If we execute the above command, it will produce the following result.

buildings table

id address
1 123 Main St
2 2 Maple St
3 98 Main St
4 5 Maple St

buildings_on_main_st table

id address
1 123 Main St
3 98 Main St